Generate an S3 signed URL using Python's AWS SDK boto.
If you just want to generate the URL of one item, it's easy to generate it directly from the connection.
conn = boto.connect_s3(aws_access_key_id, aws_secret_access_key)
url = conn.generate_url(expire_second, method='GET',
bucket='bucket_name', key='path/to/file')
This is easier if you are looking for items in your bucket.
conn = boto.connect_s3(aws_access_key_id, aws_secret_access_key)
bucket = conn.get_bucket('bucket_name')
key = bucket.get_key('path/to/file')
url = key.generate_url(expire_second)
The whole list looks like this.
bucket = (boto.connect_s3(aws_access_key_id, aws_secret_access_key)
.get_bucket('bucket_name'))
for key in bucket.get_all_keys():
print(key.generate_url(60))
Recommended Posts