Skip to content

Instantly share code, notes, and snippets.

@eswarijayakumar
Created July 14, 2023 01:17
Show Gist options
  • Save eswarijayakumar/0e29f843fd1ff722128931c6fb198a73 to your computer and use it in GitHub Desktop.
Save eswarijayakumar/0e29f843fd1ff722128931c6fb198a73 to your computer and use it in GitHub Desktop.
Python code to Generate Presigned URL for accessing S3 bucket files
import boto3
session = boto3.Session(
aws_access_key_id="<Provide your AWS access Key ID>",
aws_secret_access_key="<Provide your AWS Secret Key>",
region_name="us-east-1"
)
s3_client = session.client('s3')
url = s3_client.generate_presigned_url(
ClientMethod="get_object",
Params={
'Bucket': 'demobucket',
'Key': 'test-cover.png'
},
ExpiresIn=1800
)
print(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment