Back to All

BLOB Downloads Not Working

Hello, I have code that downloads a Blob object which is fetched from the server. I cannot seem to find a way to make it work on the emulator for either Android or iOs. Any help would be appreciated. I have a snippet of my code below:


const file = new Blob([blob.body], { type: 'application/pdf' });
const fileURL = window.URL.createObjectURL(file);
const a = document.createElement('a');
a.href = fileUrl;
a.download = "fake_filename.pdf";
a.target = '_self';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);

A resulting file URL may look as follows:
blob:http://localhost:4200/d8c93376-cfa0-4cd7-8ab0-1af4619a5c53

I have checked my "Link Handling" settings, but the only way I can seem to make it work is to set EVERYTHING to external. Which obviously defeats the purpose of an app.