Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS go SDK S3 upload with public access

I've been trying to upload an object to S3 with public access but I haven't been able to do it.

I am getting this error: InvalidArgument: Argument format not recognized status code: 400

Here is my code:

bucketName := "test-bucket"
key2 := "test.zip"
upParams := &s3manager.UploadInput{
    Bucket: &bucketName,
    Key:    &key2,
    Body:   response.Body,
    GrantRead: aws.String("uri:http://acs.amazonaws.com/groups/global/AllUsers"),
}

sess := session.Must(session.NewSession())

uploader := s3manager.NewUploader(sess)

_, err = uploader.Upload(upParams)
like image 665
NewDev Avatar asked Aug 13 '18 02:08

NewDev


1 Answers

Try ACL : "public-read" instead

bucketName := "test-bucket"
key2 := "test.zip"
upParams := &s3manager.UploadInput{
    Bucket: &bucketName,
    Key:    &key2,
    Body:   response.Body,
    ACL: "public-read",
}

sess := session.Must(session.NewSession())

uploader := s3manager.NewUploader(sess)

_, err = uploader.Upload(upParams)
like image 175
Vorsprung Avatar answered Sep 18 '22 00:09

Vorsprung