예제 #1
0
        public async Task <IHttpActionResult> Download(string archiveName, string fileName = "")
        {
            try
            {
                var result = await blobService.Download(archiveName, fileName);

                if (result == null)
                {
                    return(NotFound());
                }

                var message = Request.CreateResponse(HttpStatusCode.OK);
                message.Content = new StreamContent(result.Stream);
                message.Content.Headers.ContentLength      = result.FileSize;
                message.Content.Headers.ContentType        = new MediaTypeHeaderValue(result.ContentType);
                message.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = HttpUtility.UrlDecode(result.FileName),
                    Size     = result.FileSize
                };

                return(ResponseMessage(message));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #2
0
        public ActionResult Download()
        {
            ViewBag.Message = "Blob.";

            _blobService.Download();

            return(View("Blob"));
        }
예제 #3
0
    public Stream Process(Guid processIdentifier)
    {
        // Download your blob
        Stream currentBlob = blobService.Download(processIdentifier);

        // Process it
        MemoryStream memoryStream = new MemoryStream();

        currentBlob.CopyTo(memoryStream);
        memoryStream.Position = 0;

        StreamWriter writer = new StreamWriter(memoryStream);

        writer.Write($"Processed document at ${DateTime.Now} by Procesador.");

        return(memoryStream);
    }
예제 #4
0
        public ActionResult Download(string blobName, string donloadFileLabel)
        {
            var blobInfo = BlobInfo.FromName(blobName);

            var blobStream = _blobService.Download(blobInfo);

            if (blobStream.IsNull())
            {
                return(ErrorResult(HttpStatusCode.NotFound));
            }

            var contentDisposition = new ContentDisposition
            {
                FileName = blobInfo.BuildDownloadFileName(donloadFileLabel),
                Inline   = false
            };

            Response.AppendHeader("Content-Disposition", contentDisposition.ToString());

            return(File(blobStream, blobInfo.ContentType));
        }