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.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>