Using onProgress for items in bulkDownload
Closed this issue · 2 comments
I'd like to use the bulkDownload
option to download an array of up to 10 links, all of which are presented to the user in the form of a "card", showing name, size and a manual download-button.
Up until now everything works, had to make som minor adjustments to get a custom, dynamic path to work (or maybe I didn't check the documentations too well).
The only exception is that I'd really like to show the progress of all the downloads on the cards, and I can't seem to figure out how to do this. I'm fairly new to node but it looks like the bulkDownload
makes use of the normal download
function, and thus there might be a possibility for this to work?
Here's the relevant code from my config
window.download = function (links, elements) {
var dlPath = document.getElementById('dl-path').innerText;
DownloadManager.bulkDownload({
urls: links,
downloadFolder: dlPath + "/ZU_Downloads",
onProgress: (progress, item) => {
console.log(progress);
console.log(item.getFilename())
console.log(item.getTotalBytes())
}
}, function (error, finished, errors) {
if (error) {
console.log("finished: " + finished);
console.log("errors: " + errors);
return;
}
console.log("all finished", finished);
// Make buttons green when done
for (let element of elements) {
element.children[0].style = "background:#5d9c7d!important;transition:.2s;"
element.children[1].style = "background:#5d9c7d!important;transition:.2s;"
}
})
}
Sorry, onprogress it's not currently supported for bulk downloads (see Readme) , please use single downloads for each item you need to download to get the functionality that you use, in the future releases of the package we might add this feature
@danielnieto I'm a tad confused. I was looking for this same feature, and saw that it looks like it was introduced on January 27 in this commit:
Yet this commit isn't in the latest 2.3.0 release on NPM. Is it possible to have a new release tagged so we can make use of this?