I need to download a file from S3, and then upload the same file into a different S3 bucket. So far I have:
sess := session.Must(session.NewSession())
downloader := s3manager.NewDownloader(sess)
buffer := aws.NewWriteAtBuffer([]byte{})
n, err := downloader.Download(buffer, &s3.GetObjectInput{
Bucket: aws.String(sourceS3Bucket),
Key: aws.String(documentKey),
})
uploader := s3manager.NewUploader(sess)
result, err := uploader.Upload(&s3manager.UploadInput{
Bucket: aws.String(targetS3Bucket),
Key: aws.String(documentKey),
Body: buffer,
})
I have used an aws.WriteAtBuffer, as per the answer here: https://stackoverflow.com/a/48254996/504055
However, I am currently stuck on how to treat this buffer as something that implements the io.Reader interface, which is what the uploader's Upload method requires.