Skip to content

Commit 790e6b3

Browse files
authored
s3: Add progress tracker support to s3 downloads (#334)
This was oddly missing entirely and I was real sad. It seems to only be supported on HTTP right now.
1 parent c926030 commit 790e6b3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

get_s3.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,15 @@ func (g *S3Getter) getObject(ctx context.Context, client *s3.S3, dst, bucket, ke
173173
return err
174174
}
175175

176-
return copyReader(dst, resp.Body, 0666, g.client.umask())
176+
body := resp.Body
177+
178+
if g.client != nil && g.client.ProgressListener != nil {
179+
fn := filepath.Base(key)
180+
body = g.client.ProgressListener.TrackProgress(fn, 0, *resp.ContentLength, resp.Body)
181+
}
182+
defer body.Close()
183+
184+
return copyReader(dst, body, 0666, g.client.umask())
177185
}
178186

179187
func (g *S3Getter) getAWSConfig(region string, url *url.URL, creds *credentials.Credentials) *aws.Config {

0 commit comments

Comments
 (0)