eligrey / FileSaver.js

An HTML5 saveAs() FileSaver implementation
https://eligrey.com/blog/saving-generated-files-on-the-client-side/
Other
21.42k stars 4.38k forks source link

Cannot use blob value in saveAs from Instagram In-App Browser #754

Open Canos opened 2 years ago

Canos commented 2 years ago

a solution like:

saveAs("original-file.pdf", "new-file.pdf");

works fine in every browser i've checked also instagram browser.

But a solution based on download a blob content does not work on Instagram In-APP (but is working on Chrome, and "regular" browsers).

var url = "file.pdf";
var name = "test";
var opts = "";

var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.responseType = 'blob';

xhr.onload = function () {
        const blob = new Blob([xhr.response], { type: 'application/pdf' });
        saveAs(blob, name);
};

xhr.onerror = function () {
  console.error('could not download file');
};

xhr.send();

i've been debugging for a couple of hours and i cant really know what is happening

Any idea is welcomed

Canos commented 2 years ago

I've been digging and i have discovered the roots of the issue. Instagram in-app-browser has BLOB support. But hasnt BLOB-in-URLS support.

I mean you CANT use a or