Go through the following documentation

http://boto3.readthedocs.io/en/latest/guide/migrations3.html

Creating the Connection

Boto 3 has both low-level clients and higher-level resources. For Amazon S3, the higher-level resources are the most similar to Boto 2.x's s3 module:

Boto 2.x

import boto

s3_connection = boto.connect_s3()

Boto 3

import boto3

s3 = boto3.resource('s3')

Creating a Bucket

Creating a bucket in Boto 2 and Boto 3 is very similar, except that in Boto 3 all action parameters must be passed via keyword arguments and a bucket configuration must be specified manually:

Boto 2.x

s3_connection.create_bucket('mybucket')

s3_connection.create_bucket('mybucket', location=Location.USWest)

Boto 3

s3.create_bucket(Bucket='mybucket')

s3.create_bucket(Bucket='mybucket', CreateBucketConfiguration={
    'LocationConstraint': 'us-west-1'})

Storing Data

Storing data from a file, stream, or string is easy:

Boto 2.x

from boto.s3.key import Key

key = Key('hello.txt')

key.set_contents_from_file('/tmp/hello.txt')

Boto 3

s3.Object('mybucket', 'hello.txt').put(Body=open('/tmp/hello.txt', 'rb'))
Answer from Vaibhav Walke on Stack Overflow
🌐
AWS
docs.aws.amazon.com › boto3 › latest › reference › services › s3.html
S3 - Boto3 1.43.56 documentation
Do you have a suggestion to improve this website or boto3? Give us feedback. ... For information about using the Amazon S3 API—including authentication, signing requests, code examples, and error handling—see the Amazon S3 Developer Guide.
🌐
Medium
medium.com › featurepreneur › control-aws-s3-using-boto3-df58e7038175
Control AWS S3 using Boto3. Introduction : | by SivaraamTK | featurepreneur | Medium
August 4, 2022 - To create the Amazon S3 Bucket using the Boto3 library, you need to either create_bucket client or create_bucket resource. **NOTE: Every Amazon S3 Bucket must have a unique name. Moreover, this name must be unique across all AWS accounts and ...
🌐
Weka
docs.weka.io › additional-protocols › s3 › s3-examples-using-boto3
S3 examples using boto3 | W E K A
May 18, 2026 - This page provides some examples of using the S3 API. Boto3, the official AWS SDK for Python, is used to create, configure, and manage AWS services.
🌐
Reddit
reddit.com › r/aws › python, boto3, and aws s3: demystified - a good guide for beginners
r/aws on Reddit: Python, Boto3, and AWS S3: Demystified - A good guide for beginners
March 11, 2021 - Learn how to create objects, upload them to S3, download their contents, and change their attributes directly from your script, all while avoiding common pitfalls. ... Thanks. Was wanting to learn Boto3. Articles from ... Boto3 is just epic. It really works well. I write tools for AWS for our dev team to use and · python3 + boto3 give you a solid way to do this.
🌐
GitHub
github.com › boto › boto3
GitHub - boto/boto3: Boto3, an AWS SDK for Python · GitHub
4 days ago - $ git clone https://github.com/boto/boto3.git $ cd boto3 $ python -m pip install -r requirements.txt $ python -m pip install -e . ... Next, set up credentials (in e.g. ~/.aws/credentials): [default] aws_access_key_id = YOUR_KEY aws_secret_access_key = YOUR_SECRET · Then, set up a default region (in e.g. ~/.aws/config): ... >>> import boto3 >>> s3 = boto3.resource('s3') >>> for bucket in s3.buckets.all(): print(bucket.name)
Author   boto
Find elsewhere
Top answer
1 of 4
27

Go through the following documentation

http://boto3.readthedocs.io/en/latest/guide/migrations3.html

Creating the Connection

Boto 3 has both low-level clients and higher-level resources. For Amazon S3, the higher-level resources are the most similar to Boto 2.x's s3 module:

Boto 2.x

import boto

s3_connection = boto.connect_s3()

Boto 3

import boto3

s3 = boto3.resource('s3')

Creating a Bucket

Creating a bucket in Boto 2 and Boto 3 is very similar, except that in Boto 3 all action parameters must be passed via keyword arguments and a bucket configuration must be specified manually:

Boto 2.x

s3_connection.create_bucket('mybucket')

s3_connection.create_bucket('mybucket', location=Location.USWest)

Boto 3

s3.create_bucket(Bucket='mybucket')

s3.create_bucket(Bucket='mybucket', CreateBucketConfiguration={
    'LocationConstraint': 'us-west-1'})

Storing Data

Storing data from a file, stream, or string is easy:

Boto 2.x

from boto.s3.key import Key

key = Key('hello.txt')

key.set_contents_from_file('/tmp/hello.txt')

Boto 3

s3.Object('mybucket', 'hello.txt').put(Body=open('/tmp/hello.txt', 'rb'))
2 of 4
10

First, in boto3, if you setup security using "aws configure" , you don't need to declare that "sess" section (http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)

# if you already done aws configure
import boto3
s3 = boto3.client("s3")
s3.create_bucket(Bucket="mybucket", ....) 

Second, is the bad boto3 documentation that fail to link proper information. This is found under boto3 pdf, page 2181 (https://media.readthedocs.org/pdf/boto3/latest/boto3.pdf)

Email : The value in the Grantee object is the registered email address of an AWS account.

Grantee : The AWS user or group that you want to have access to transcoded files and playlists. To identify the user or group, you can specify the canonical user ID for an AWS account, an origin access identity for a CloudFront distribution, the registered email address of an AWS account, or a predefined Amazon S3 group

And the easier solution is just use policy setting (http://support.cloudcheckr.com/getting-started-with-cloudcheckr/preparing-your-aws-account/aggregate-cloudtrail/) . You can convert the whole stuff using put_bucket_policy(), skip the dire GrantWrite,GrantWriteACP

🌐
Akamai
techdocs.akamai.com › cloud-computing › docs › using-the-aws-sdk-for-python-boto3-with-object-storage
Use the AWS SDK for Python (boto3) with Object Storage
March 1, 2026 - Add the following code to your python script, replacing [access-key] and [secret-key] with the values generated in the previous step. Also replace [cluster-url] with the cluster URL corresponding to the data center your buckets are located within (listed on the Access buckets and files through URLs page). import boto3 linode_obj_config = { "aws_access_key_id": "[access-key]", "aws_secret_access_key": "[secret-key]", "endpoint_url": "[cluster-url]", } client = boto3.client("s3", **linode_obj_config)
🌐
PyPI
pypi.org › project › boto3
boto3 · PyPI
June 12, 2026 - $ git clone https://github.com/boto/boto3.git $ cd boto3 $ python -m pip install -r requirements.txt $ python -m pip install -e . ... Next, set up credentials (in e.g. ~/.aws/credentials): [default] aws_access_key_id = YOUR_KEY aws_secret_access_key = YOUR_SECRET · Then, set up a default region (in e.g. ~/.aws/config): ... >>> import boto3 >>> s3 = boto3.resource('s3') >>> for bucket in s3.buckets.all(): print(bucket.name)
      » pip install boto3
    
Published   Jul 28, 2026
Version   1.43.58
🌐
DEV Community
dev.to › aws-builders › how-to-list-contents-of-s3-bucket-using-boto3-python-47mm
How to List Contents of s3 Bucket Using Boto3 Python? - DEV Community
October 12, 2021 - Invoke the list_objects_v2() method with the bucket name to list all the objects in the S3 bucket. It returns the dictionary object with the object details. Iterate the returned dictionary and display the object names using the obj[key]. Note: Similar to the Boto3 resource methods, the Boto3 client also returns the objects in the sub-directories.
Top answer
1 of 7
311

There is a customization that went into Boto3 recently which helps with this (among other things). It is currently exposed on the low-level S3 client, and can be used like this:

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 reading/writing files as well as doing multipart uploads in parallel for large files.

Note that s3_client.download_file won't create a directory. It can be created as pathlib.Path('/path/to/file.txt').parent.mkdir(parents=True, exist_ok=True).

2 of 7
90

boto3 now has a nicer interface than the client:

resource = boto3.resource('s3')
my_bucket = resource.Bucket('MyBucket')
my_bucket.download_file(key, local_filename)

This by itself isn't tremendously better than the client in the accepted answer (although the docs say that it does a better job retrying uploads and downloads on failure) but considering that resources are generally more ergonomic (for example, the s3 bucket and object resources are nicer than the client methods) this does allow you to stay at the resource layer without having to drop down.

Resources generally can be created in the same way as clients, and they take all or most of the same arguments and just forward them to their internal clients.

🌐
Real Python
realpython.com › python-boto3-aws-s3
Python, Boto3, and AWS S3: Demystified – Real Python
August 4, 2023 - With its impressive availability and durability, it has become the standard way to store videos, images, and data. You can combine S3 with other services to build infinitely scalable applications. Boto3 is the name of the Python SDK for AWS.
🌐
AWS
docs.aws.amazon.com › boto3 › latest › reference › services › s3 › object
Object - Boto3 1.43.38 documentation
Do you have a suggestion to improve this website or boto3? Give us feedback · S3 / Resource / Object
🌐
Medium
medium.com › featurepreneur › useful-methods-for-boto3-in-s3-611a15eab616
Useful methods for Boto3 in S3. Introduction: | by SivaraamTK | featurepreneur | Medium
August 6, 2022 - import boto3client = boto3.client(‘s3’,aws_access_key_id=”XXXXXXX”,aws_secret_access_key=”YYYYYYY”,region_name=”us-east-1") *NOTE: Storing your AWS credentials in your scripts is not secure and, you should never do this, we can set them as environment variables or use `.env` file and load it into the Python script but even storing AWS Access and Secret Keys in a plain text file is not very secure.
🌐
AWS
docs.aws.amazon.com › boto3 › latest › guide › s3-examples.html
Amazon S3 examples - Boto3 1.43.54 documentation
Do you have a suggestion to improve this website or boto3? Give us feedback. ... Amazon Simple Storage Service (Amazon S3) is an object storage service that offers scalability, data availability, security, and performance. This section demonstrates how to use the AWS SDK for Python to access ...
🌐
PyPI
pypi.org › project › mypy-boto3-s3
mypy-boto3-s3 · PyPI
Install boto3-stubs for S3 service. # install with boto3 type annotations python -m pip install 'boto3-stubs[s3]' # Lite version does not provide session.client/resource overloads # it is more RAM-friendly, but requires explicit type annotations python -m pip install 'boto3-stubs-lite[s3]' # standalone installation python -m pip install mypy-boto3-s3
      » pip install mypy-boto3-s3
    
Published   Jul 16, 2026
Version   1.43.50
🌐
Saturn Cloud
saturncloud.io › blog › python-aws-boto3-how-to-read-files-from-s3-bucket
Python AWS Boto3: How to Read Files from S3 Bucket | Saturn Cloud Blog
May 1, 2026 - In this blog post, we’ll explore how to read files from an S3 bucket using Boto3, the Amazon Web Services (AWS) SDK for Python.
🌐
YouTube
youtube.com › playlist
Boto3 - S3 - Python
AboutPressCopyrightContact usCreatorsAdvertiseDevelopersTermsPrivacyPolicy & SafetyHow YouTube worksTest new featuresNFL Sunday Ticket · © 2026 Google LLC · Boto3 - S3 - Python - YouTube
🌐
GeeksforGeeks
geeksforgeeks.org › cloud computing › read-file-content-from-s3-bucket-with-boto3
How to Read File Content from S3 Bucket with Boto3 ? - GeeksforGeeks
July 23, 2025 - AWS S3 (Simple Storage Service), ... of data, at any time, from anywhere. Boto3 is the AWS Software Development Kit (SDK) for Python, which provides an object-oriented API for AWS ......