Download S3 Objects With Python and Boto 3
In this post we show examples of how to download files and images from an aws S3 bucket using Python and Boto 3 library.
Boto is an AWS SDK for Python. It provides easy to use functions that can interact with AWS services such as EC2 and S3 buckets.
Dowload S3 Objects With Python and Boto 3
In the following example, we download one file from a specified S3 bucket.
First we have to create an S3 client using .
The method takes three parameters:
The first parameter is the bucket name in S3. The second is the file (name and extension) we want to download and the third parameter is the name of the file we want to save as.
Download All S3 Objects in a Specified Bucket
In the following example, we download all objects in a specified S3 bucket.
The code snippet assumes the files are directly in the root of the bucket and not in a sub-folder.
Download All Objects in A Sub-Folder S3 Bucket
The following code shows how to download files that are in a sub-folder in an S3 bucket.
Suppose the files are in the following bucket and location:
References
Boto 3 Documentation
Share this on: Twitter LinkedIn
Источник: [rushbrookrathbone.co.uk]
-
-
-