getting "The bucket does not allow ACLs" Error

Viewed 12316

This is my bucket policy

{
    "Version" : "2012-10-17",
    "ID" : "************",
    "Statement" : [
        {
            "Sid" : "************",
            "Effect" : "Allow",
            "Principar" : "*",
            "Action" : [
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:GetObject",
                "s3:GetObjectAcl"
            ],
            "Resource" : "************************"
        }
    ]
}

{ "Version" : "2012-10-17", "ID" : "", "Statement" : [ { "Sid" : "", "Effect" : "Allow", "Principar" : "", "Action" : [ "s3:PutObject", "s3:PutObjectAcl", "s3:GetObject", "s3:GetObjectAcl" ], "Resource" : "***********************" } ] }

and here's the code I used to upload image:

    [HttpPost]
    public bool UploadFile(string file)
    {
        var s3Client = new AmazonS3Client(accesskey, secretkey, RegionEndpoint.APSoutheast1);

        var fileTransferUtility = new TransferUtility(s3Client);
            if (file.Length > 0)
            {
                var filePath = file;
                var fileTransferUtilityRequest = new TransferUtilityUploadRequest
                {
                    BucketName = bucketName,
                    FilePath = filePath,
                    StorageClass = S3StorageClass.StandardInfrequentAccess,
                    PartSize = 6291456, // 6 MB.  
                    Key = keyName,
                    CannedACL = S3CannedACL.PublicRead
                };
                fileTransferUtilityRequest.Metadata.Add("param1", "Value1");
                fileTransferUtilityRequest.Metadata.Add("param2", "Value2");
                fileTransferUtility.Upload(fileTransferUtilityRequest);
                fileTransferUtility.Dispose();
            }
        return true;
    }

and getting "The bucket does not allow ACLs" even setting it to "ACLs enabled" in object ownership

2 Answers

You should be able to go to the AWS S3 console and navigate to the bucket details for the bucket you try to write objects to. You'll see a tab called 'Permissions'. There you have the option to change the "Object Ownership" at a block with te same title.

Once there, you can choose the option "ACLs enabled".

After applying those changes, you should be able to write objects with ACL options.

@Rutger 's answer is correct, and now it's 2022, aws console has changed ( not a lot ,but some what ), so let me show the images:

1.assume you have created the s3 bucket, in the list page,

enter image description here

2.don't toggle the "block" options

enter image description here

3.find the ownership, then click edit.

enter image description here

4.edit the object owner ship (ACLs enabled) enter image description here

5.now the edit button for ACL is clickable.

enter image description here

6.toggle the permissions you want and save changes.

enter image description here

it's done, now you can upload images to s3 via commandline and then visit them in your browser:

enter image description here

Related