I am upgrading a legacy java application that used AWS SDK v1.5 for S3 operations, and one of the functions it had to do was to change an objects ACL, from private to public-read, based on certain conditions. The v1.5 AmazonS3 had a method for this, simple as:
s3client.setObjectAcl(bucketName, s3Key, acl);
But it appears that feature or capability doesn’t exist in v2.21.2. I’ve looked through all the posted examples and documentation, and found a rather complex example of how to change the ACL for a bucket, but I need to be able to set a single object acl to public-read or back to private, not the whole bucket.
How do I do this in AWS SDK v2.21.x?
3
Answers
Quasnoi pointed me in the right direction. My method ended up looking something like this:
I went to the Java SDK S3 Client documentation and just did a full page search for "ACL". I see there are two
putObjectAcl
methods, which are exactly what you are looking for.In v2, they renamed some of the methods to match API action names:
You’re looking for
putObjectAcl
, which is a wrapper forPutObjectAcl
API action.