I'm making a POST call to my server with response type arraybuffer
and it is currently returning a PDF blob with the following headers:
"Content-Type": "application/pdf"
"Content-Transfer-Encoding": "binary"
"Content-Disposition": "attachment;filename=file.pdf\"
I then create a blob url from the response:
var url = URL.createObjectURL(blob);
Is there any way to trigger a file download for this blob that works cross browser? I want the standard file download to occur as if the user had clicked on a link such as <a href="/file.pdf"></a>
.
I've tried:
- Using the url as the SRC for a script tag and it gets the blob, but no download
- Using it as the url for an iFrame
- Using it as the data url for object and embed tags, but it displays the object instead of downloading it