Ejemplo n.º 1
0
        public async Task <IActionResult> GetImage(Guid Id)
        {
            MemoryStream ms = new MemoryStream();

            var response = await this.context.GetModelAsync(Id);

            BlobStorageService blobStorageService = new BlobStorageService();
            var container = blobStorageService.GetContainerFromStorage();

            if (await container.ExistsAsync())
            {
                CloudBlob file = container.GetBlobReference(response.Url);

                if (await file.ExistsAsync())
                {
                    await file.DownloadToStreamAsync(ms);

                    Stream blobStream = file.OpenReadAsync().Result;
                    return(File(blobStream, file.Properties.ContentType, file.Name));
                }
                else
                {
                    return(Content("File does not exist"));
                }
            }
            else
            {
                return(Content("Container does not exist"));
            }
        }