Skip to content

Instantly share code, notes, and snippets.

@bobbidigital
Created February 24, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bobbidigital/f12e1156cb3b728b72fb to your computer and use it in GitHub Desktop.
Save bobbidigital/f12e1156cb3b728b72fb to your computer and use it in GitHub Desktop.
Generate a Signed URL that Expires (Python)
import boto
import boto.s3.connection
access_key = ''
secret_key = ''
conn = boto.connect_s3(
aws_access_key_id = access_key,
aws_secret_access_key = secret_key,
#is_secure=False, # uncomment if you are not using ssl
calling_format = boto.s3.connection.OrdinaryCallingFormat(),
)
bucket = conn.get_bucket('grubhub-example-bucket')
apk_file = bucket.get_key('/path/to/filename.txt')
# expires_in is epoch time
apk_file_url = apk_file.generate_url(expires_in=1738254231, expires_in_absolute=1, query_auth=True, force_http=True)
print apk_file_url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment