Reputation: 459
I am trying to use Azure Blob Storage as a location for secure file downloads using Shared Access Signature. Everything is working very well, however the problem I am having is I am trying to allow the user to save files from the browser and I have all browsers except IE9 working.
Reviewing this question,
What content type to force download of text response?
this works well when I can control all of the headers, however in Azure Blob Storage, I have set the Content-Type to application/octet-stream and this allows all browsers except IE to ask the user to save the file, IE simply opens the file. It appears that known file types will open (example .jpg, .wmv etc…).
In Azure, I have found no way to set
Content-Disposition: attachment;filename="My Text File.txt"
Is there a way, using Azure Blob Storage, to use IE to download any file directly from Azure Blob Storage?
Thanks in advance.
Upvotes: 3
Views: 1459
Reputation: 621
If you're using the @azure/storage-blob
package for uploading blobs with SAS, you can force the file to be downloaded by setting the Content Disposition as shown below.
In the following example, a *.png image file is downloaded when linked to rather than the browser default of opening in a new tab:
blockBlobClient.upload(file.content, file.size, {
blobHTTPHeaders: {
blobContentType: "image/png",
blobContentDisposition: "attachment"
}
});
Upvotes: 0
Reputation: 60153
I don't think there's a way to set the Content-Disposition
header in Windows Azure blob storage.
Upvotes: 2