Code Examples#. This section describes code examples that demonstrate how to use the AWS SDK for Python to call various AWS services. The source files for the examples, plus additional example programs, are available in the AWS Code Catalog.. To propose a new code example for the AWS documentation team to consider producing, create a new request.
A low-level client representing Amazon S3 on Outposts (S3 Outposts) Amazon S3 on Outposts provides access to S3 on Outposts operations. import boto3 client = boto3 . client ( 's3outposts' )
will return bytes. At least for Python 3, if you want to return a string, you have to decode using the right encoding:read
import boto3
s3 = boto3.resource('s3')
obj = s3.Object(bucket, key)
obj.get()['Body'].read().decode('utf-8')
You can create a session:
import boto3
session = boto3.Session(
aws_access_key_id=settings.AWS_SERVER_PUBLIC_KEY,
aws_secret_access_key=settings.AWS_SERVER_SECRET_KEY,
)
Then use that session to get an S3 resource:
s3 = session.resource('s3')
Through a bit of trial and error, found out the instance type that can be used:
>>> import boto3
>>> import botocore
>>> isinstance(boto3.client('s3'), botocore.client.BaseClient)
True