This repository is a sample with the purpose of demonstrating how to use the golang AWS S3 SDK.
Because this code was written in a tutorial, we do not follow appropriate error handling conventions. Please do not use this code in production.
func uploadObject(filename string) (resp *s3.PutObjectOutput) {
f, err := os.Open(filename)
if err != nil {
panic(err)
}
fmt.Println("Uploading:", filename)
resp, err = s3session.PutObject(&s3.PutObjectInput{
Body: f,
Bucket: aws.String(BUCKET_NAME),
Key: aws.String(strings.Split(filename, "/")[1]),
ACL: aws.String(s3.BucketCannedACLPublicRead),
})
if err != nil {
panic(err)
}
return resp
}