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

Reader oriented encoder #210

Open
oakad opened this issue Nov 8, 2023 · 3 comments
Open

Reader oriented encoder #210

oakad opened this issue Nov 8, 2023 · 3 comments

Comments

@oakad
Copy link
Contributor

oakad commented Nov 8, 2023

Right now, Writer is used for compression and Reader is used for decompression. However, some storage APIs, namely AWS S3 and kind, insist on having a Reader as a body of file to upload.

S3 style APIs are incredibly popular and will stay with us for the indefinite future.

We, of course, can work around this limitation by means of a helper goroutine and an io.Pipe, but this adds quite a bit of overhead when many objects are to be uploaded in compressed form.

From the look of it, it should not be too difficult to make an EncodingReader object, which takes a plain data Reader as a parameter and exposes a Reader for compressed data (that is, performs a logical opposite of the presently available lz4.Reader object).

I think, such a feature will be most useful for people using cloud storage.

@pierrec
Copy link
Owner

pierrec commented Nov 12, 2023

Hello, it makes sense to have it. I currently dont have time to work on this but am open to PRs :).

@oakad
Copy link
Contributor Author

oakad commented Nov 13, 2023

Kind of weird how http.Request requires reader for the body, yet Go supplied compressors, like gzip, have not support for handling it. Nobody cares about uploads? :-)

oakad added a commit to oakad/lz4_issue_210 that referenced this issue Nov 13, 2023
In Go, `http.Request` requires an `io.ReadCloser` for an upload body. To
facilitate compression of data being uploaded we want to wrap a
source reader (such an `io.File`) with a proposed
`lz4.CompressingReader`, whereupon the said reader can be set directly
into `http.Request` Body field.

This benefits not only the plain `http.Request`, but also the various
network file storage APIs which build on top of Go's http client.

Signed-off-by: Alex Dubov <oakad@yahoo.com>
@oakad
Copy link
Contributor Author

oakad commented Nov 13, 2023

Added a pull request (#211) . Seems to work.

pierrec added a commit that referenced this issue Dec 8, 2023
CompressingReader: compressed data reader stream (#210)
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