user2982886
user2982886

Reputation: 11

Prompt Save dialog box while downloading blob from azure storage

I have an ASP.NET web application to download blobs from my azure storage. When I use blockBlob.DownloadToStream(fileStream); it automatically downloads it to the project location when run the web aplication in local machine. But if I want to deploy this web aplication in cloud, How can I get a dialog box to save the blobs to be dowloaded ?

Upvotes: 1

Views: 529

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136346

There are two things you could do:

  1. Set the content-type property of the blob to application/octet-stream or don't set the content type of the blob at all. While this approach may work in most of the browsers but not in all. IE is quite smart about this would actually try to read the file type from the file stream and decides if to display the file in the browser or to prompt "Save As".
  2. Download the blob first on your web server and then serve that file by setting the Content Disposition response header value to something like `attachment; filename="Your file name"'.

Upvotes: 1

Related Questions