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

Build an archive from a stream #42

Open
Rudloff opened this issue May 2, 2017 · 2 comments
Open

Build an archive from a stream #42

Rudloff opened this issue May 2, 2017 · 2 comments

Comments

@Rudloff
Copy link

Rudloff commented May 2, 2017

Hello,

I need to build tarballs from streams on my server (coming from HTTP requests or processes).
Do you think it would be possible to have a function that takes a stream as an argument instead of a filename, so I could do something like this:

$zip->add_stream(popen('echo foo'));
@mootari
Copy link

mootari commented May 3, 2017

@Rudloff Here's what I did to wrap remote files. While written for Drupal, the code should be mostly reusable and self-explanatory: https://gist.github.com/mootari/463a0e5ec31f7db314c323ac47d26d3a

Hope it helps. :)

Edit: I doubt you'll be able to do this if you don't know the stream size in advance, though. In that case you should propbably revert to compression formats that have better support for this, like gzip.

@Rudloff
Copy link
Author

Rudloff commented May 4, 2017

Thanks @mootari. I also ended up extending TarArchive in order to fill my specific needs: https://github.com/Rudloff/alltube/blob/develop/classes/PlaylistArchiveStream.php

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

2 participants