I'm using NodeJs
(expressJs) and archiver
module to stream zip file to the client, so the final ZIP file do not existe in server storage (streaming zip serving
), but the probleme is that i can't get the size of the output file because the zip process happen in real time.
Code :
var archiver = require('archiver');
var files = ["file1","file2"];
var zipper = archiver('zip');
zipper.on('error', function(err) {
res.status(500).send({
error: err.message
});
});
res.attachment('output.zip');
res.setHeader('Content-Type', 'application/zip');
zipper.pipe(res);
files.forEach(f => {
zipper.file(f, {
name: f
});
});
zipper.finalize();