{"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
@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,
2.don't toggle the "block" options
3.find the ownership, then click edit.
4.edit the object owner ship (ACLs enabled)
5.now the edit button for ACL is clickable.
6.toggle the permissions you want and save changes.
it's done, now you can upload images to s3 via commandline and then visit them in your browser:
When working with buckets, it is important to understand the limitations and restrictions that may be in place regarding ACLs (Access Control Lists). One such limitation is that some buckets do not allow ACLs at all.
ACLs provide a way to control access to your bucket and its contents. They allow you to specify which users or groups have permission to perform certain actions, such as read or write data.
However, in some cases, the bucket itself may have settings that prevent the use of ACLs. This means that you cannot modify the permissions for individual objects within the bucket.
If you encounter a bucket that does not allow ACLs, you may need to explore alternative methods for controlling access to the bucket and its contents. One option is to use IAM (Identity and Access Management) policies, which allow you to define fine-grained access control rules.
Another option is to consider using bucket policies, which are similar to IAM policies but are specific to S3 buckets. Bucket policies allow you to define rules for access control at the bucket level, rather than at the individual object level.
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.