Skip to content

Instantly share code, notes, and snippets.

@csmith0651
Created May 25, 2016 13:00
Show Gist options
  • Save csmith0651/c37f84e3119a08738c826811ab39cce0 to your computer and use it in GitHub Desktop.
Save csmith0651/c37f84e3119a08738c826811ab39cce0 to your computer and use it in GitHub Desktop.
func downloadS3Data(fetcher S3Fetcher, bucket string, key string) ([]byte, error) {
results, err := fetcher.GetObject(&s3.GetObjectInput{
Bucket: aws.String(bucket),
Key: aws.String(key),
})
if err != nil {
return nil, err
}
defer results.Body.Close()
buf := bytes.NewBuffer(nil)
if _, err := io.Copy(buf, results.Body); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment