I make requests for files using the request module.
And how to make each query result (file) recorded in a zip archive immediately using streams and channels?
(To, without temporarily saving to a file on disk, adding to the archive and deleting later).
Something like this: rq.pipe (gzip). Pipe (wstream);
function downloadImage(url, idx, callback){ var dst = __dirname + "/uploads/"+req.body.Id+".gz"; var wstream = fs.createWriteStream(dst); var gzip = zlib.createGzip(); var rq = request(url); rq.on('error', function (err) { if (err.code === 'ETIMEDOUT') { console.log("ERRORR!!"); rq.end(); callback(err.code); }}); wstream.on("finish", function() { console.log(".on(finish " + idx + " " + dst); rq.end(); callback(dst); }) rq.pipe(gzip).pipe(wstream); } But in this my code, if there are a lot of files, they will be written glued together .. And I need that in a normal way .. each file is written separately, all in one archive.
How to do this? Can others have modules instead of zlib?