I am looking for an implementation which allows downloading a file from a path as a zip
I have copy this code: https://cheatcode.co/tutorials/how-to-create-and-download-a-zip-file-with-node-js-and-javascript
Howeve, when i try to download a folder a run into this error:
download(f) {
if (!f) f = this.state.selectedItem;
let links = f.map((obj)=>{
return this.backend().directLink(obj.id, true);
})
this.downloadAndZip(links);
}
downloadByOne = url => {
return fetch(url).then(resp => resp.blob());
};
downloadByGroup = (urls, files_per_group=5) => {
return Promise.map(
urls,
async url => {
return await this.downloadByOne(url);
},
{concurrency: files_per_group}
);
}
exportZip = blobs => {
const zip = JsZip();
if(Array.isArray(blobs))
blobs.forEach((blob, i) => {
zip.file(`file-${i}`, blob);
});
else
zip.file(`file`, blobs);
zip.generateAsync({type: 'blob'}).then(zipFile => {
const currentDate = new Date().getTime();
const fileName = `combined-${currentDate}.zip`;
return FileSaver.saveAs(zipFile, fileName);
});
}
downloadAndZip = urls => {
return this.downloadByGroup(urls, 5).then(this.exportZip);
}
}
Is there any way of download a directory as a zip from a URL? i am using webix file manager
is there any file manager which does this?