by

Amazon S3 Aws - Change an object's acl using boto API

This code shows how to change the access rights on a file uploaded on S3 storage.     
This example sets the object foo_bar.txt to be publicly readable, and secret.txt to be private.

Supported acl values defined in boto.gs.acl.py.

CannedACLStrings = ['private', 'public-read', 'project-private', 'public-read-write', 'authenticated-read', 'bucket-owner-read', 'bucket-owner-full-control']

Learn more about CannedACLStrings: [https://github.com/boto/boto/blob/develop/boto/gs/acl.py](https://github.com/boto/boto/blob/develop/boto/gs/acl.py)
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/5885/Amazon-S3-Aws---Change-an-object-s-acl-u?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
# Public ACL example # Here you get the key reference for file foo_bar.txt foo_bar_key = bucket.get_key('foo_bar.txt') # This set the foo_bar file publicly readable foo_bar_key.set_canned_acl('public-read') # Private ACL example # Here you get the key reference for file secret.txt secret_key = bucket.get_key('secret.txt') # This set the secret.txt file as private secret_key.set_canned_acl('private')
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus