Created
January 29, 2022 11:31
-
-
Save arundhaj/134775031ef916301c9aeff4c089466c to your computer and use it in GitHub Desktop.
AWS S3 Presigned URL for upload and download
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pprint import pprint | |
import boto3 | |
session = boto3.Session(profile_name='arundhaj') | |
s3_client = session.client('s3') | |
s3_bucket_name = 'codepossibility-presigned' | |
object_name = 'TestUploadFile.txt' | |
def create_bucket(): | |
response = s3_client.create_bucket(Bucket=s3_bucket_name) | |
pprint(response) | |
def file_upload(): | |
response = s3_client.generate_presigned_post( | |
s3_bucket_name, | |
object_name, | |
ExpiresIn=3600 | |
) | |
pprint(response) | |
def file_download(): | |
response = s3_client.generate_presigned_url( | |
'get_object', | |
Params={ | |
'Bucket': s3_bucket_name, | |
'Key': object_name | |
}, | |
ExpiresIn=3600 | |
) | |
pprint(response) | |
# create_bucket() | |
# file_upload() | |
file_download() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boto3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment