How to download files from AWS S3 using Python?

AWS SDK for Python have a default download_file method that we can easy to use. That method accepts the names of the bucket and object to download and the filename to save the file to.

1. Download and install boto3 library

$ pip install boto3

2. Download file from S3

# importing the boto3 library 
import boto3
# connect to S3 using boto3 client
s3_client = boto3.client(service_name='s3')
# download file from S3
s3_client.download_file('<bucket-name>', '<s3-file-name>', '<local-file-name>')

That’s it. I hope this will help. ?
Photo: https://www.brandeps.com

Leave a Reply

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