Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-3079

Implement io.ReadSeeker for the DownloadStream

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 2.1.0
    • Affects Version/s: None
    • Component/s: GridFS, Networking, Performance
    • None

      Context

      As the client, I should have the flexibility of choosing to stream a file in it's entirety or in parts, such as using a Range Request

      Here is the current definition of the DownloadStream

      func (ds *DownloadStream) Skip(skip int64) (int64, error)

      Whereas the http.ServeContent function requires a an `io.ReadSeeker`. From the docs, it seem this is the recommended function to use 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.

      By extending the type to implement the `ReadSeeker` interface, this creates greater consistency with the stdlib

      Definition of done

      Include a method for seeking. This seems to exists in s3 compatible drivers already and  this older unofficial MongoDB driver seemed to also implement this. The official driver also already seems to tackle the SeekStart/SeekCurrent with how Skip is implemented.

      Pitfalls

      What should the implementer watch out for? What are the risks?

            Assignee:
            Unassigned Unassigned
            Reporter:
            kristopherab@gmail.com Kristopher Rahim Afful-Brown
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: