Skip to content

Instantly share code, notes, and snippets.

@Allwin12
Last active May 23, 2020 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Allwin12/edc12e89ce73c86c4b6b78db58547d88 to your computer and use it in GitHub Desktop.
Save Allwin12/edc12e89ce73c86c4b6b78db58547d88 to your computer and use it in GitHub Desktop.
from boto3 import Session
import string
import random
ACCESS_KEY = "your access key"
SECRET_KEY = "your_secret_key"
REGION_NAME = "your bucket's region name"
BUCKET_NAME = "your bucket name"
ses = Session(aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY,
region_name=REGION_NAME)
client = ses.client('s3')
key = "The same key that you used while uploading the object"
url = client.generate_presigned_url(
ClientMethod='get_object',
Params={
'Bucket': BUCKET_NAME,
'Key': key,
},
ExpiresIn=600
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment