Diego Cotini
Diego Cotini

Reputation: 1069

Issue uploading object PublicRead to Amazon S3 using .NET

I have an issue to upload PublicRead objects to Amazon S3 corporate bucket.

I have a personal Amazon S3 account and I can upload using code bellow using S3CannedACL.PublicRead to a Private bucket I've created, but when I try to do it using corporate bucket I get an Access Denied error. If I remove S3CannedACL.PublicRead I can upload objects to this corporate bucket, also I can delete and download after uploading but I cannot access object through a public URL and I need to do it.

        var amazonFileName = Guid.NewGuid();

        var request = new PutObjectRequest()
        {
            BucketName = _amazonBucketName,
            InputStream = fileStream,
            Key = amazonFileName.ToString(),
            CannedACL = S3CannedACL.PublicRead
        };

        var result = _amazonClient.PutObject(request);

It seems some lack of permission or something like that but I don't have access to this corporate account so it's a bit hard to figure out what is happening there. In my personal account I just needed to create the bucket.

Does anybody know what is missing on this corporate bucket/account to allow uploading PublicRead objects?

Upvotes: 1

Views: 823

Answers (1)

user9244629
user9244629

Reputation:

This is caused by not having the correct permissions on the associated AWS credentials. Specifically you will need to permission s3:PutObjectAcl. This can be configured in IAM.

Hope that helps!

Upvotes: 4

Related Questions