set object ACL via the JetS3t API

80 views
Skip to first unread message

casimi...@gmail.com

unread,
Apr 7, 2009, 12:48:34 PM4/7/09
to JetS3t Users
Hello,

Can anyone describe how to handle in the following situation:

During the creation of a S3Object (via the JetS3t API),
how do I set a S3Object's ACL to public read for all users?
(the object has to be uploaded to an existing bucket)

James Murty

unread,
Apr 7, 2009, 1:02:08 PM4/7/09
to jets3t...@googlegroups.com
To set an object's ACL to public-read when you upload it, you can use what is known as "canned" ACL settings. Set your object's ACL prior to upload like so:

s3ObjectToUpload.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);

The following canned ACL settings are available:

AccessControlList#REST_CANNED_PRIVATE
AccessControlList#REST_CANNED_PUBLIC_READ
AccessControlList#REST_CANNED_PUBLIC_READ_WRITE
AccessControlList#REST_CANNED_AUTHENTICATED_READ

You can set any AccessControlList settings you like prior to uploading JetS3t objects, but the canned versions are the most efficient because they use special headers in the original HTTP request to apply the settings. Non-canned ACL settings, such as more complex permissions, will cause JetS3t to perform a follow-up HTTP request to set the permissions *after* the original object is uploaded.

Hope this helps,
James

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

casimi...@gmail.com

unread,
Apr 7, 2009, 1:40:34 PM4/7/09
to JetS3t Users
Thanks James,

It works perfectly!

Before, I was indeed trying the Non-canned ACL settings, (permissions,
grands, S3owner) and got into problems...

Casimir
Reply all
Reply to author
Forward
0 new messages