Ejemplo n.º 1
0
        public async Task 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(image.Name);
            blockBlob.Properties.ContentType = image.ContentType;

            // finally, upload the image into blob storage using the block blob reference
            var fileBytes = image.Data;
            await blockBlob.UploadFromByteArrayAsync(fileBytes, 0, fileBytes.Length);
        }
Ejemplo n.º 2
0
        public async Task<ActionResult> Upload(FormCollection formCollection)
        {
            var model = new UploadedImage();
            
            if (Request != null)
            {
                HttpPostedFileBase file = Request.Files["uploadedFile"];
                model = await _imageService.CreateUploadedImage(file);
                
                // hard-coded adding one thumbnail for now
                model.Thumbnails.Add(new Thumbnail { Width = 200, Height = 300 });
                
                await _imageService.AddImageToBlobStorageAsync(model);
                await _queueService.AddMessageToQueueAsync(model.Name, model);
            }

            return View("Index", model);
        }