3 ms·
Anybody know how to dynamically zip things on the fly? Like if you want to generate a download for a user that has files and folders... how can you do this fast
by marknadal 13y ago
Anybody know how to dynamically zip things on the fly? Like if you want to generate a download for a user that has files and folders... how can you do this fast and in one go? Currently I have to literally write to disk, then zip it, and only then can I finally send a response. Any help?
- jeresig 13y agoAbsolutely! Poking around I found one module that could do it - I'm sure there are more (and better ones, too): https://github.com/wellawaretech/node-zipstream https://github.com/wellawaretech/node-zipstream In the example there you would .pipe() out to an HTTP response rather than a file, presumably.
- marknadal 13y agoSweet, thanks. I think I had found this a while ago but lost it, looks great! ...holy smokes, John Resig just replied to me. Thanks so much for jQuery, it has changed my life and is what made me become a programmer. (I now do client work for 20<20Thiel Fellows, and my startup has been in WSJ - none of which would have been the case if I hadn't started programming with jQuery!)
- maxogden 13y agofor an example of doing this with tar instead of zip check out https://npmjs.org/package/dir-tar-stream https://npmjs.org/package/dir-tar-stream
- contrahax 13y agonode-archiver is the best ive used so far... imo