How do you determine your permissions in AWS S3 through the Java SDK?


I know you can try to read the ACLs or Bucket Policies through the Java SDK, but is there any easy way to just check if you have read and/or write permissions to a bucket and/or its contents? I don't see any "haveReadPermissions()" method or anything in the AmazonS3 class, but maybe I'm missing something? I find it hard to believe there's no easy way to check permissions.


I do not think there is an easier way unless you created your own classes that extended the AWS API. Which might not be a bad idea if you are doing a larger program having to do with Amazon S3.

By : Brinnis

Using getBucketACL is fine if there are no Bucket Policies defined, but the Policy can override the ACL.

Also you may not have permission to view the ACL. So unless you can require READACL access to the Buckets, and don't allow Policies, you will need to use some combination of getBucketACL and getBucketPolicy.

And at that point it is probably easier to try the operations you need to check for those permissions.

By : Jimmy

This video can help you solving your question :)
By: admin