示例#1
0
        public void ImageCropFactory(string s)
        {
            UploadedImage upImage = GetCurrentImageTable(s);

            AddImageToBlobStorageAsync(upImage);
            ModifyImagesTableContainer(upImage);
        }
示例#2
0
        public void ModifyImagesTableContainer(UploadedImage image)
        {
            image.Data     = null;
            image.CropData = null;

            CloudTable     table           = GetImagesTable();
            TableOperation updateOperation = TableOperation.Replace(image);

            table.Execute(updateOperation);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }