Azure download blob filestream/memorystream

后端 未结 2 1522
我寻月下人不归
我寻月下人不归 2020-12-18 01:43

I want users to be able to download blobs from my website. I want the fastest/cheapeast/best way to do this.

Heres what i came up with:

        Cloud         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-18 01:56

    Your code is almost right. Try this:

        public virtual ActionResult DownloadFile(string name)
        {
            Response.AddHeader("Content-Disposition", "attachment; filename=" + name); // force download
            CloudBlobContainer blobContainer = CloudStorageServices.GetCloudBlobsContainer();
        CloudBlockBlob blob = blobContainer.GetBlockBlobReference(blobName);
            blob.DownloadToStream(Response.OutputStream);
            return new EmptyResult();
        }
    

    Hope this helps.

提交回复
热议问题