Amazon S3 expiring URLs with Boto

If you’re using the Boto python wrapper for the Amazon S3 service, you can quickly generate temporary URLs for your private files.

1
2
3
4
from boto.s3.connection import S3Connection
 
s3 = S3Connection('YOUR_KEY', 'YOUR_SECRET', is_secure=False)
url = s3.generate_url(60, 'GET', bucket='YOUR_BUCKET', key='YOUR_FILE_KEY', force_http=True)
This will give you a URL to your private file on S3 that will only work for 60 seconds. It will look something like this:
http://mycoolbucket.s3.amazonaws.com/myfile.jpg?

Signature=ABC123DEF456&
Expires=1312216031&
AWSAccessKeyId=ABCDEFGHIJKLMNOP


Comments

Popular Posts