Exemplo n.º 1
0
        public async Task <IActionResult> UploadNewImage(IFormFile file, string title, string tags)
        {
            var blob      = _photoService.GetBlobContainer(AzureConnectionString, "photos");
            var content   = ContentDispositionHeaderValue.Parse(file.ContentDisposition);
            var fileName  = content.FileName.Trim('"');
            var blockBlob = blob.GetBlockBlobReference(fileName);
            await blockBlob.UploadFromStreamAsync(file.OpenReadStream());

            await _photoService.SetImage(title, tags, blockBlob.Uri);

            return(RedirectToAction("Index", "Photo"));
        }