Setting Bucket ACL

View: New views
2 Messages — Rating Filter:   Alert me  

Setting Bucket ACL

by Ryan Asleson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello,

What's the recommended way to set a bucket's ACL via the JetS3t API?  I
see the S3Service API includes a createBucketImpl method that takes an
ACL as a method argument, but this method is protected.

When creating a bucket (or even with an existing bucket) how do I change
its ACL?

Thank you, and great job on JetS3t!!!!

-Ryan



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Setting Bucket ACL

by James Murty-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Ryan,

You can set a bucket's ACL by using either the S3Service#createBucket
or S3Service#putBucketAcl methods, depending on whether it is a new or
existing bucket. In both cases, you need to attach an
AccessControlList object to the S3Bucket object that you pass into the
methods.

The easiest way to create an AccessControlList object is to retrieve
an ACL from S3, then modify it to meet your needs. Here is some
example code from the Samples.java tutorial:

        // Retrieve the bucket's ACL and modify it to grant public access,
        // ie READ access to the ALL_USERS group.
        AccessControlList bucketAcl = s3Service.getBucketAcl(publicBucket);
        bucketAcl.grantPermission(GroupGrantee.ALL_USERS,
Permission.PERMISSION_READ);

        // Update the bucket's ACL. Now anyone can view the list of
objects in this bucket.
        publicBucket.setAcl(bucketAcl);
        s3Service.putBucketAcl(publicBucket);

Check out the Samples page online for more code snippets like this:
http://jets3t.s3.amazonaws.com/toolkit/code-samples.html#acls

Cheers,
James

---
http://www.jamesmurty.com



On Mon, Sep 1, 2008 at 1:41 PM, Ryan Asleson <ryan.asleson@...> wrote:

>
> Hello,
>
> What's the recommended way to set a bucket's ACL via the JetS3t API?  I see
> the S3Service API includes a createBucketImpl method that takes an ACL as a
> method argument, but this method is protected.
>
> When creating a bucket (or even with an existing bucket) how do I change its
> ACL?
>
> Thank you, and great job on JetS3t!!!!
>
> -Ryan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...