public void ImageCropFactory(string s) { UploadedImage upImage = GetCurrentImageTable(s); AddImageToBlobStorageAsync(upImage); ModifyImagesTableContainer(upImage); }
public void ModifyImagesTableContainer(UploadedImage image) { image.Data = null; image.CropData = null; CloudTable table = GetImagesTable(); TableOperation updateOperation = TableOperation.Replace(image); table.Execute(updateOperation); }
public void AddImageToBlobStorageAsync(UploadedImage image) { // get the container reference var container = GetImagesBlobContainer(); // using the container reference, get a block blob reference and set its type CloudBlockBlob blockBlob = container.GetBlockBlobReference("Crop_" + image.Name); blockBlob.Properties.ContentType = image.ContentType; // finally, upload the image into blob storage using the block blob reference var fileBytes = image.CropData; blockBlob.UploadFromByteArray(fileBytes, 0, fileBytes.Length); }
public UploadedImage GetCurrentImageTable(string RowId) { UploadedImage image = new UploadedImage(); CloudTable table = GetImagesTable(); TableQuery <UploadedImage> query = new TableQuery <UploadedImage>(); image = table.ExecuteQuery(query).Where(p => p.RowKey == RowId).FirstOrDefault(); var container = GetImagesBlobContainer(); CloudBlockBlob blockBlob = container.GetBlockBlobReference(image.Name); using (var memoryStream = new MemoryStream()) { blockBlob.DownloadToStream(memoryStream); image.Data = memoryStream.ToArray(); } image.URLcrop = string.Format("{0}/{1}", _imageRootPath, "Crop_" + image.Name); image.CropData = CreateImageThumbnail(image.Data, 280, 180); return(image); }