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

Source#readZip() #1462

Open
vanniktech opened this issue Mar 28, 2024 · 4 comments
Open

Source#readZip() #1462

vanniktech opened this issue Mar 28, 2024 · 4 comments

Comments

@vanniktech
Copy link
Contributor

Counterpart of what I wrote here #1442 (comment)

When the user is choosing for instance on Android from the file picker a file, I can get an InputStream quite easily. Which I can also call source() on but from there I don't get an easy way of reading it as a zip file. I could as a workaround write it to a file and then call openZip() but I think it's beneficial to have a readZip() directly on a Source so that any source is readable as a Zip.

@swankjesse
Copy link
Member

Unfortunately the thing we need to read a zip FileSystem isn’t a Source (streaming) but rather a FileHandle (random access).

@vanniktech
Copy link
Contributor Author

That makes sense. Does InputStream have random access? If not, how is ZipInputStream able to use an InputStream?

@JakeWharton
Copy link
Member

JakeWharton commented Mar 28, 2024

ZipInputStream reads valid entries from the beginning of the stream through to the end. Only once at the end do you reach the central index and can realize that some of the entities you saw were not in the directory and thus were old/fake/malicious.

@JakeWharton
Copy link
Member

Still worth doing, in my opinion, as it has its uses too. Just gotta put a big caveat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants