Category Archives: BOTO3

HOW TO SAVE S3 OBJECT TO A FILE USING BOTO3?

How to save S3 object to a file using boto3?

Advantages:
s3_client = boto3.client(‘s3′)
open(‘hello.txt’).write(‘Hello, world!’)
# 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())
These functions will automatically handle read/write files as well as doing multipart uploads in parallel for large files.