I am creating a website using Azure Blobs to store content. The website provides Search and Indexing.
When this link is relative,
<a download="" href="./media5/yyy.png">Download</a>
the browser kicks off a "download".
When the files are stored in Blobs, the users get a link like:
<a download="" href="https://xxx.blob.core.windows.net/media5/yyy.png">Download</a>
However, this navigates to the image.
I need the browser "download" to work.
I have tries setting the Storage Account’s CORS Blade:
But this did not do anything.
2
Answers
Manrti is correct CORS is not in play. I deleted the Storage Account's CORS Blade.
The fix is 3 parts: 1: Set ContentDispoistion header to "attached"
2: You must use a SAS Url to have the Content-Disposition header be returned:
3: HTML Link:
CORS is not going to help in this case. If you want to force download the blob, please change the blob’s content-type property to
application/octet-stream
(orapplication/binary
).However, please note that when you change the blob’s content type to
application/octet-stream
, it will always be downloaded. You will not be able to display the blob in the browser.