-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing zip files in a streaming manner #9
Comments
I have 3 proposal of how we could create our read api. first i would like to give some background so you can understand some of the obstacle of reading a zip file. The best solution is to read the end of the file and being able to seek/jump too different places multiple times. To do that we need to know the length of the file either by blob/file size or content-length header or some sort of fileLike object. Doing a slice on http would just clone a Request object and just change content-range header. But sometimes you don't always know the zip content length. So you need to get the hole body before you are able to read something, for example.
So if the size (in our FileLike object) is not a number (could be NaN, null, or undefined) then we would read the content using only // using async iterator (current form)
for await (const entry of read(blob || readableStream)) {
console.log(entry)
}
// just a iterator that returns promise
for (const it of read(blob || readableStream)) {
const { value: entry, done } = await it
}
read(blob || readableStream).pipeTo(new WritableStream({
write (entry) {
console.log(entry)
}
}))
// this could be fine for blob object but not so much for streams
const entries = await read(blob || readableStream)
const entry = entries[0]
console.log(entry) |
fyi, i have figured out how to read zip64 formats now. (a bit more complicated) but i can grasp it now) When i have manage to read it i can start working on making a zip64 file. |
...without reading the hole content of the zip file
thinkwe need to read it backwards, read the last bytes that tells how large the central dictionary is read that many bytes.(not exactly sure)old stuff
Some basic idea of how it could work.
The text was updated successfully, but these errors were encountered: