5

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)

1 Answer 1

15

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)
Sign up to request clarification or add additional context in comments.

2 Comments

As of Sep. 2020, I believe the SDK has changed to expect passing aws.String(...) in many cases. So here it would be aws.String("public-read")
thanks Brian. I don't have time to test this (I'm sure you are correct) so I'll just leave it as an upvoted comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.