Failed to load blob file using Firefox, but it works in Chrome?

Here is my download code:

var mimeType = this.getMime(obj);
var ab = this.base64ToArrayBuffer(obj[key]);
var blob = new Blob([ab.buffer], {
    type : mimeType
});
var result = this.bintostring(blob);
var url = window.URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = result.filename;
a.target = '_blank';
a.click();
window.URL.revokeObjectURL(url);

During debugging, I see no exceptions.

+4
source share
1 answer

To add a Firefox file to the file must be executed. Firefox does not do this automatically, unlike Chrome

a.download = result.filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
+6
source

Source: https://habr.com/ru/post/1650786/


All Articles