Upload file to S3 bucket
Tags: #aws #cloud #storage #S3bucket #snippet #operations# AWS - Upload file to S3 bucket
Description: This notebook provides instructions on how to upload a file to an Amazon Web Services (AWS) S3 bucket, allowing for secure storage and easy access to the file. It is a simple and efficient way to store and manage data in the cloud.
try:
import boto3
except:
!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
)
with open(BUCKET_OBJECT_KEY, "rb") as f:
s3.upload_fileobj(f, BUCKET_NAME, BUCKET_OBJECT_KEY)
Last modified 1mo ago