Skip to content

Add ability to stream binary data on stderr and stdout outputs #34

@piotrmurach

Description

@piotrmurach

As suggested by @janko-m, this library would benefit from ability to stream binary data chunk by chunk to stdout/stderr when available from the running process.

I didn't want to first download the whole remote file onto disk, and then start streaming the downloaded file into the response, because then the user would have to wait for the whole file to get downloaded by the server before it can start downloading it from the server (which isn't ideal if these are videos that you want to play), also it would use unnecessary disk space, even if it will get deleted at the end.
I wanted to stream the remote file to the response as it is being downloaded. So I told wget to redirect to stdout. But I couldn't capture a simple string stdout here, because it would mean that the whole file would be loaded into memory. I knew that Open3.popen3 uses Ruby pipes for stdin/stdout/stderr, which are readable/writable IO objects, so after a lot of fiddling I managed to utilize it. It would be great that instead TTY::Command provides some wrapper for that.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions