jimmywarting / StreamSaver.js

StreamSaver writes stream to the filesystem directly asynchronous
https://jimmywarting.github.io/StreamSaver.js/example.html
MIT License
4.04k stars 418 forks source link

Writing ZIP files #119

Closed brainboutique closed 5 years ago

brainboutique commented 5 years ago

Example at zip-stream.js is really neat and helped a lot. Though noticed two isses that others may run into as well:

a) On Windows all ZIPs appear empty BUT the file size is reasonable. After digging a bit: Windows is confused by file and folder names starting with a "/". If you omit these, ZIPs work perfectly on Windows.

b) I believe there is an issue with closing the stream: I believe this should happen after the resource was streamed completely - apparenly only causing issues for larger files:

            ctrl.enqueue({ name, stream })
            ctrl.close()

I solved this via Promise.

PS: Great work, would strongly encourage to merge this into the library ;-)

jimmywarting commented 5 years ago

Thanks for reporting that. Nobody have reported issues with windows and I have never tried windows since i only run on Mac.

A: might or might not change how the zip lib works and just leave that up to the developer to do what is right instead. maybe will throw error if it starts with /

B: hmm, should be fine to close it once everything is enqueue, then again i simulate some things since i didn't use writableStream (for a reason) and the controller isn't a real stream controller