Boto3 S3上传和下载

python
阅读 50 收藏 0 点赞 0 评论 0

boto3_s3_func.py
# If bucket is private
AWS_ACCESS_KEY = 'your access key'
AWS_SECRET_KEY = 'your secret key'
AWS_REGION = 'your region'

session = boto3.session.Session(
  aws_access_key_id=AWS_ACCESS_KEY,
  aws_secret_access_key=AWS_SECRET_KEY,
  region_name=AWS_REGION
)
s3_client = session.client('s3')

# If the bucket is public
s3_client = boto3.client('s3')
open('hello.txt').write('Hello, world!')

# Once the client is created.

# Upload the file to S3
s3_client.upload_file('hello.txt', 'MyBucket', 'hello-remote.txt')

# Download the file from S3
s3_client.download_file('MyBucket', 'hello-remote.txt', 'hello2.txt')
print(open('hello2.txt').read())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号