7 // WithProgress allows for a user to track
8 // the progress of a download.
9 // For example by displaying a progress bar with
11 // Not all getters have progress support yet.
12 func WithProgress(pl ProgressTracker) func(*Client) error {
13 return func(c *Client) error {
14 c.ProgressListener = pl
19 // ProgressTracker allows to track the progress of downloads.
20 type ProgressTracker interface {
21 // TrackProgress should be called when
22 // a new object is being downloaded.
23 // src is the location the file is
25 // currentSize is the current size of
26 // the file in case it is a partial
28 // totalSize is the total size in bytes,
29 // size can be zero if the file size
31 // stream is the file being downloaded, every
32 // written byte will add up to processed size.
34 // TrackProgress returns a ReadCloser that wraps the
35 // download in progress ( stream ).
36 // When the download is finished, body shall be closed.
37 TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser)