Filesaver.js: saveAs saves only last saveAs request, used to be able to save multiple files, Firefox

Created on 6 Feb 2019  路  10Comments  路  Source: eligrey/FileSaver.js

A JavaScript in an html file run from the desktop used to be able to save multiple text files from multiple saveAs calls that look similar to this:

var text = simplekey + "\r\n\r\nReference answer key string:\r\n" + refanswerkey;
var filename = basefile+"_SimpleKey"; if ( versions.length > 1 ) { filename += "s" }
var blob = new Blob([text],{type: "text/plain;charset=utf-8"});
saveAs(blob, filename+".txt");

But now just today (2-5-2019), even using the same html files as before, only the last saveAs request actually works. No errors are generated by the other requests, just no files are generated. If I comment out the last saveAs, then the second-last request produces a file. Firefox v65.0.

Most helpful comment

I have now found a similar issue in Chrome when the number of files to be written is greater than 8 or 9. Sometimes the issue goes away, sometimes it comes back.

All 10 comments

From a UX perspective i would first zip all files then save the hole thing.
for future references i would have used the writable-files when it gets adopted to ask for write permission to a folder

Functionality of my script is fine in Chrome, Version 72.0.3626.96 (Official Build) (64-bit), suggesting that my problem is an issue with Firefox and not the script, the types of files it is saving, or Filesaver.js. As this only just started occurring with the latest version of Firefox, it is presumably a setting within Firefox, but I cannot yet find where one might prevent or enable downloading of multiple files by a script running in a tab.

Hello @wormguy

I am experiencing the same issue in Firefox.
For me it works in:

  • Chrome (same for you)
  • Edge
  • Even IE11!

NOTE: It is not working on Firefox nightly as well.

Update: It looks like a bug in FF. In some cases; Adding set timeout or request animation frame solves the issue.

JSFiddle: https://jsfiddle.net/mboughaba/wake4mbt/12/
Firefox Bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1528457

_I am convinced that it is not an issue with FileSaver itself._

Cheers

I have now found a similar issue in Chrome when the number of files to be written is greater than 8 or 9. Sometimes the issue goes away, sometimes it comes back.

I confirm the same issue in Firefox.

Im not using Filesaver, but it similar bcz im using xmlhttprequest to make a blob response and get it. It can be only save 2/3 number of files.

I am also seeing same issue, downloading blob and saving using filesaver. If user downloads 120 files only 20 are being actually saved.

The firefox bug regarding multiple download was fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=1528457

I suggest filing new bug to the target browser if problem can be reproduced.

Thanks mboughaba, I confirm the issue has been fixed and recent versions of Firefox are not experiencing the problem. Multiple files are saving properly from JavaScript using filesaver.js.

Thanks I guess this issue can be closed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bholyfield picture bholyfield  路  6Comments

josepoma picture josepoma  路  4Comments

danielbronder picture danielbronder  路  6Comments

strobec picture strobec  路  4Comments

Toterbiber picture Toterbiber  路  5Comments