[PYTHON] Generate S3 signed URL with boto

Generate an S3 signed URL using Python's AWS SDK boto.

Generate only URL

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')

Create a Bucket object and then create it

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))

reference

Recommended Posts

Generate S3 signed URL with boto
S3 uploader with boto
Issue S3 time-limited URL with boto3 (with file existence confirmation)
Generate a Pre-Signed URL with golang
Use boto3 to mess with S3
Issue a signed URL with AWS SQS
Try server-side encryption on S3 with boto3
S3 server-side encryption SSE with Python boto3
[Go] Deliver private content with CloudFront signed URL
Manipulate S3 objects with Boto3 (high-level API and low-level API)
URL shortening with Python
Region specification with boto
[Memo] Load csv of s3 into pandas with boto3
I wanted to delete multiple objects in s3 with boto3
Set connection timeout with boto3
[S3] CRUD with S3 using Python [Python]
Generate XML (RSS) with Python
Generate URL query from JSON
Change retry settings with boto3
Generate Pokemon with Deep Learning