Comments (9)
No, because it's not really possible without sacrificing correctness. The master table of contents is at the end of a .zip file, not the beginning, so a streaming API would need to either buffer the entire .zip file (defeating the purpose of a streaming interface) or rely on the "local file header" information. The local file headers are explicitly denounced in the spec as being unreliable copies of the "central directory" information at the end of the file, so trusting them would be wrong.
Every streaming API I've seen in other libraries has made this mistake without realizing it or caring that they're wrong. It's pretty rare to see a .zip file where the unreliable info is actually incorrect, so test-driven confidence will probably lead most naive library aythors astray.
I haven't looked closely yet at the library you linked, but the above would be my first guess at how they implemented it.
from yauzl.
No, you are spot on and most likely the reason why every single streaming unzipping library I've found has had issues. Looks like I'll be loading the whole file into memory to unzip it rather than streaming it straight through to Swift.
Thanks for your time!
from yauzl.
No problem. I'm happy for an opportunity to soapbox :)
from yauzl.
If you're expecting large zip files you might want to buffer in a temp file instead of memory. Depends on your use case of course.
from yauzl.
@andrewrk: I'm not expecting huge ones and it's not a feature that will be used all that frequently. I'm using Hapi.js as the web server and they give you the chance to either send the uploaded files to the buffer or a temp file.
@thejoshwolfe: Interestingly enough, I tried to use your Buffer option but I was getting an error from your dependency on fd-slicer
. It was saying that the use of process.nextTick
in a recursive manner would be deprecated in the next release of NodeJS. It only happened with a zip file (500kB) that has 600+ files. So I've changed over to the default .open()
method for now and it's working great! Thanks a ton!!
from yauzl.
I changed fd-slicer to use setImmediate
instead of nextTick
and published a new version of yauzl. Want to try again with the buffer interface?
from yauzl.
@andrewrk I should have been more observant, I didn't realise you were the author of fd-slicer
:).
Yes, after that update it's working great! Thanks for that. Now I don't have to worry about cleaning up any temporary files.
Cheers!
from yauzl.
I was just checking your personal website and I saw you were into a bit of music. You might find one of my libraries quite fun. It's called Band.js
. You can find it here: https://github.com/meenie/band.js. Here's an example of what it can do: http://plnkr.co/edit/LG20SL?p=preview
from yauzl.
As this issue has surfaced again, I'd like to add a few more thoughts. It's possible to support a streaming unzip api and still be correct if there's a check at the end of the stream that can report an error that basically tells you that everything you thought about this zip was a lie. The more I think about how this API would work and how clients would be supposed to use it, the less I like it. So the summary is that I still don't think supporting this feature is a good idea.
from yauzl.
Related Issues (20)
- Serialise entry item HOT 4
- Buffer deprecated warning HOT 3
- error : invalid central directory file header signature: 0x5053884e HOT 1
- Unable to unzip hidden files HOT 1
- Unable to open correct Zip64 files with 0xffff as "number of this disk" in eocdr HOT 1
- [Feature Request] Support for AES-256 decryption HOT 1
- bug and workaround when running from win executable created with pkg HOT 1
- invalid comment HOT 1
- How to open password protected zip files HOT 2
- Failure when readstream doesn't have the unpipe method implementation
- calculating progress for the whole archive. HOT 3
- Opening of archive with entry named "/" fails HOT 3
- Invalid signature causes process to close unexpectedly HOT 2
- how to handle different values for extraFieldLength in local file header vs central directory file header HOT 2
- use bigint HOT 1
- Unzipping nested folders from archive HOT 1
- What file types are supported? HOT 1
- end of central directory record signature not found HOT 2
- Uncaught Error: ENOENT: no such file or directory, open xxx file path HOT 1
- Alternative library: yauzl-promise HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yauzl.