From 790e6b346a517a8ec4ddf2860029ace16eac6bd6 Mon Sep 17 00:00:00 2001 From: Matt Robenolt Date: Mon, 16 Aug 2021 02:40:45 -0700 Subject: [PATCH] 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. --- get_s3.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/get_s3.go b/get_s3.go index d897ab50c..ec864428e 100644 --- a/get_s3.go +++ b/get_s3.go @@ -173,7 +173,15 @@ func (g *S3Getter) getObject(ctx context.Context, client *s3.S3, dst, bucket, ke return err } - return copyReader(dst, resp.Body, 0666, g.client.umask()) + body := resp.Body + + if g.client != nil && g.client.ProgressListener != nil { + fn := filepath.Base(key) + body = g.client.ProgressListener.TrackProgress(fn, 0, *resp.ContentLength, resp.Body) + } + defer body.Close() + + return copyReader(dst, body, 0666, g.client.umask()) } func (g *S3Getter) getAWSConfig(region string, url *url.URL, creds *credentials.Credentials) *aws.Config {