Hacker News new | past | comments | ask | show | jobs | submit login

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?



Absolutely! 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

In the example there you would .pipe() out to an HTTP response rather than a file, presumably.


Sweet, 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!)


for an example of doing this with tar instead of zip check out https://npmjs.org/package/dir-tar-stream


node-archiver is the best ive used so far... imo




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: