AWS s3 downloading files from the bucket using python sdk (boto3)

By | 17th March 2019

Continuing with my series on AWS s3, this week I am exploring on downloading the files from the bucket using boto3 .

If you need to locally download the files from a particular bucket, this script will help you with the same. You just need to provide the bucket name and it will check all the folders available in the bucket and download the files. For more details check https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Bucket.download_file

Example: The files are downloaded to the tmp directory locally from where we are running the scripts.

script

https://github.com/rajeevrn/myscripts/blob/master/aws/downloadbucketfiles.py

Output::

Bucket from which the objects will be downloaded: thecloudopsbucket
Files which will be downloaded: awsfileSecondfile.txt
Downloaded location of the file is: /tmp/awsfileSecondfile.txt
Files which will be downloaded: awsfiletest.txt
Downloaded location of the file is: /tmp/awsfiletest.txt

Leave a Reply

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