nats-io / nats.go

Golang client for NATS, the cloud native messaging system.
https://nats.io
Apache License 2.0
5.45k stars 686 forks source link

Implement the `io.ReadSeeker` interface for the `ObjectResult` type #1508

Open adoublef opened 9 months ago

adoublef commented 9 months ago

Proposed change

As a user I want to be able to made HTTP Range Requests to the server for large byte data that is persisted in the NATS object store. The official Go std lib offers a method http.ServeContent which is recommended over io.Copy as it:

handles Range requests properly, sets the MIME type, and handles If-Match, If-Unmodified-Since, If-None-Match, If-Modified-Since, and If-Range requests.

This requires the content to have the Seek which currently the ObjectResult does not therefore it can't yet benefit from this standard method

Use case

Partial requests for large data can be useful for streaming large content like video. This gives the client (assuming web client) greater flexibility with caching downloads, efficiency with parallel requests to name a few.

Contribution

If I learn that this could be possible, I would be keen to contribute.

ilCollez commented 2 days ago

Any updates on this? This feature would be much appreciated

Jarema commented 2 hours ago

We will get back to this shortly. Sorry for the delay!