I have a PDF file that downloads across all browsers except for Firefox/Safari. It opens it in the browser window instead of download of the file. My site is running on top of node.js and hosted in Azure. The file users download is coming from Azure blob storage, so I suspect this may be a CORS issue.
Here is my client side code for the download:
<a href="{{fileURL}}" class="btn btn-default" download="myfile.pdf">Download File</a>
Here is the server side code:
$scope.fileURL = 'https://myblob.blob.core.windows.net/8282020/myfile.pdf';
Update: I am able to add the content disposition by setting the blob properties in Azure per the help below, and it is showing the disposition as "attachment" but in FireFox/Safari it is still opening in the browser. Is this possibly being blocked since Azure Blob storage might be viewed as CORS?
Update 2: Adding the following to my HTML tag seems to work in FireFox (but not Safari), what is this the right way to handle this across Browsers
type="application/octet-stream"
Update 3: Setting the content disposition and content type via Node appears to be working. I have to ask, is this the right way?
blobSvc.setBlobProperties(containerName, filename, { contentDisposition: 'attachment', contentType: 'application/octet-stream' }, function (error, result, response) {
// result code here....
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With