IMHO, the cheapest and fastest solution will be directly downloaded from the blob repository. At the moment, your code first downloads blob to your server and passes from there. Instead, you can create a Shared Access Signature permission with Read and Content-Disposition permission and create a blob URL on it and use that URL. In this case, the blob content will be directly transferred from the repository to the client browser.
For example, look at the code below:
public ActionResult Download() { CloudStorageAccount account = new CloudStorageAccount(new StorageCredentials("accountname", "accountkey"), true); var blobClient = account.CreateCloudBlobClient(); var container = blobClient.GetContainerReference("container-name"); var blob = container.GetBlockBlobReference("file-name"); var sasToken = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy() { Permissions = SharedAccessBlobPermissions.Read, SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(10),//assuming the blob can be downloaded in 10 miinutes }, new SharedAccessBlobHeaders() { ContentDisposition = "attachment; filename=file-name" }); var blobUrl = string.Format("{0}{1}", blob.Uri, sasToken); return Redirect(blobUrl); }
Gaurav mantri
source share