lz4 icon indicating copy to clipboard operation
lz4 copied to clipboard

Reader oriented encoder

Open oakad opened this issue 2 years ago • 3 comments

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.

oakad avatar Nov 08 '23 08:11 oakad

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

pierrec avatar Nov 12 '23 18:11 pierrec

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 avatar Nov 13 '23 02:11 oakad

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

oakad avatar Nov 13 '23 06:11 oakad