Skip to content

Instantly share code, notes, and snippets.

@jsidew
Last active January 14, 2021 12:56
Show Gist options
  • Save jsidew/435c975e4e85d21502a6e43bda488734 to your computer and use it in GitHub Desktop.
Save jsidew/435c975e4e85d21502a6e43bda488734 to your computer and use it in GitHub Desktop.
// from (2020-01-14) https://docs.aws.amazon.com/sdk-for-go/api/service/s3/s3manager/#Downloader.DownloadWithIterator
svc := s3manager.NewDownloader(session)
fooFile, err := os.Open("/tmp/foo.file")
if err != nil {
return err
}
barFile, err := os.Open("/tmp/bar.file")
if err != nil {
return err
}
objects := []s3manager.BatchDownloadObject {
{
Object: &s3.GetObjectInput {
Bucket: aws.String("bucket"),
Key: aws.String("foo"),
},
Writer: fooFile,
},
{
Object: &s3.GetObjectInput {
Bucket: aws.String("bucket"),
Key: aws.String("bar"),
},
Writer: barFile,
},
}
iter := &s3manager.DownloadObjectsIterator{Objects: objects}
if err := svc.DownloadWithIterator(aws.BackgroundContext(), iter); err != nil {
return err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment