Skip to content
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

Implement a PartialReader #14

Open
digitaldogsbody opened this issue Oct 5, 2022 · 0 comments
Open

Implement a PartialReader #14

digitaldogsbody opened this issue Oct 5, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@digitaldogsbody
Copy link
Owner

Per discussion with Diego on Slack, it would be good to avoid copying all the data for a compressed file stream into memory before returning it to the user, and instead have a way of streaming it directly from the source zipfile.

Slack conversation:

Mike Bennett
[5:31 PM]
Today's shower thoughts - I am not 100% happy with using php://temp when retrieving a stream for inside the zip. We can't just attach the zlib.inflate filter to the main stream, because then the end user has to handle knowing where to seek to and how much data to read (rather than just being able to while(!feof($fp)) on the returned pointer), so the general pattern has to stay, but rather than opening the temp and doing stream_copy_to_stream directly, maybe we could implement a PartialReader that implements the interface required by fread and can be passed to the end user instead.
[5:33]
This would eliminate the need to use php://temp as we could just create the new class directly (instantiating it with the offset and length) and pass that to the end user from ::getStream().
[5:33]
I think this is broadly similar to what you were talking about in this comment: #8 (comment)

Diego Pino
[6:15 PM]
I will go pragmatic here. The main question is, if you are extracting a file from the ZIP, what is the most plausible thing you will do with it? I would say, save locally/do something with it or deliver as download.
[6:16]
So, that said, PartialReader sounds good

@digitaldogsbody digitaldogsbody added the enhancement New feature or request label Oct 5, 2022
@digitaldogsbody digitaldogsbody added this to the 0.9 milestone Oct 5, 2022
@digitaldogsbody digitaldogsbody self-assigned this Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant