Get files from S3 bucket
Tags: #aws #cloud #storage #S3bucket #operations #snippet #url
Description: This notebook provides a step-by-step guide to retrieving files from an Amazon Web Services (AWS) S3 bucket, allowing users to easily access their data stored in the cloud.
!pip install boto3 getpass4
import boto3
ACCESS_KEY_ID = "**********"
SECRET_ACCESS_KEY = "**********"
BUCKET_NAME = "naas-example"
BUCKET_OBJECT_KEY = "naas_happy_hour.mp3"
s3 = boto3.client(
"s3", aws_access_key_id=ACCESS_KEY_ID, aws_secret_access_key=SECRET_ACCESS_KEY
)
fileObj = s3.get_object(Bucket=bucketname, Key=filename)
file_url = s3.generate_presigned_url(
"get_object",
Params={"Bucket": BUCKET_NAME, "Key": BUCKET_OBJECT_KEY},
ExpiresIn=604800,
)
fileOBJ
file_url
Last modified 1mo ago