-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Downloading multiple files at once #331
Comments
Is this still an issue? Does this need a PR to implement? |
I think my actual issue was regarding the browser blocking any downloads after the initial. Our solution was to just update the security settings of our browsers to allow our site to download multiple files. We are pretty close to release so I don't know if we will upgrade to the latest version, but I can try it locally after the weekend. |
I'm having the same issue with Chrome 65. Here is a snippet that reproduces the problem: import { saveAs } from 'file-saver'
for(const index of [ ...Array(5).keys() ]) {
console.log(index)
var blob = new Blob(["Hello world!"], {type: "text/plain;charset=utf-8"});
saveAs(blob, `hello-world-${index}.txt`);
} This snippet only downloads the last file, Here is a repl.it to try it: https://repl.it/@PelleJacobs/SaveAsMultipleFiles |
Does saveAs use promises? |
No. The task is not async. Even doe the writing to the hard drive is async, we have no way of knowing when it has finish writing. |
same issue here... any updates, please? |
I am still getting this error. Is there any workaround for this? |
@leondroidgeeks We use the following workaround It's not perfect, but it works for us. download = async () => {
for(const index of [ ...Array(5).keys() ]) {
console.log(index)
var blob = new Blob(["Hello world!"], {type: "text/plain;charset=utf-8"})
saveAs(blob, `hello-world-${index}.txt`)
await new Promise(setTimeout)
}
} |
@pellejacobs it's tricky! thanks
|
In a sequential call:
saveAs(new Blob(...), "a.txt");
saveAs(new Blob(...), "b.txt");
saveAs(new Blob(...), "c.txt");
I got 3 download of the same file that was last set.
I think that this is due to the improper scope of the variable save_link defined in
var saveAs = saveAs || (Function (view) {
...
, save_link = doc.createElementNS ("http://www.w3.org/1999/xhtml", "a")
, can_use_save_link = "download" in save_link
...
}
The definition of the save_link object in
, FileSaver = function (blob, name, no_auto_bom) {
...
, save_link = doc.createElementNS ("http://www.w3.org/1999/xhtml", "a")
, can_use_save_link = "download" in save_link
...
}
solves the problem of multiple downloads
Please fix this problem.
The text was updated successfully, but these errors were encountered: