Shows how to use the AWS SDK for Python (Boto3) to work with Amazon Simple Storage Service (Amazon S3).
Amazon S3 is storage for the internet. You can use Amazon S3 to store and retrieve any amount of data at any time, from anywhere on the web.
- Running this code might result in charges to your AWS account. For more details, see AWS Pricing and Free Tier.
- Running the tests might result in charges to your AWS account.
- We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see Grant least privilege.
- This code is not tested in every AWS Region. For more information, see AWS Regional Services.
For prerequisites, see the README in the python folder.
Install the packages required by these examples by running the following in a virtual environment:
python -m pip install -r requirements.txt
- Hello Amazon S3 (
ListBuckets)
Code examples that show you how to perform the essential operations within a service.
Code excerpts that show you how to call individual service functions.
- CopyObject
- CreateBucket
- DeleteBucket
- DeleteBucketCors
- DeleteBucketLifecycle
- DeleteBucketPolicy
- DeleteObject
- DeleteObjectAnnotation
- DeleteObjects
- GetBucketAcl
- GetBucketCors
- GetBucketLifecycleConfiguration
- GetBucketPolicy
- GetObject
- GetObjectAcl
- GetObjectAnnotation
- GetObjectLegalHold
- GetObjectLockConfiguration
- HeadBucket
- ListBuckets
- ListObjectAnnotations
- ListObjectsV2
- PutBucketAcl
- PutBucketCors
- PutBucketLifecycleConfiguration
- PutBucketPolicy
- PutObject
- PutObjectAcl
- PutObjectAnnotation
- PutObjectLegalHold
- PutObjectLockConfiguration
- PutObjectRetention
Code examples that show you how to accomplish a specific task by calling multiple functions within the same service.
- Create a presigned URL
- Create an Amazon Textract explorer application
- Detect entities in text extracted from an image
- Detect objects in images
- Detect people and objects in a video
- Make conditional requests
- Manage object annotations
- Manage versioned objects in batches with a Lambda function
- Upload or download large files
- Work with versioned objects
This example shows you how to get started using Amazon S3.
python s3_basics/hello.py
This example shows you how to do the following:
- Create a bucket and upload a file to it.
- Download an object from a bucket.
- Copy an object to a subfolder in a bucket.
- List the objects in a bucket.
- Delete the bucket objects and the bucket.
Start the example by running the following at a command prompt:
python s3_basics/scenario_getting_started.py
This example shows you how to create a presigned URL for Amazon S3 and upload an object.
Start the example by running the following at a command prompt:
python s3_basics/presigned_url.py
This example shows you how to explore Amazon Textract output through an interactive application.
This example shows you how to use Amazon Comprehend to detect entities in text extracted by Amazon Textract from an image that is stored in Amazon S3.
This example shows you how to build an app that uses Amazon Rekognition to detect objects by category in images.
This example shows you how to detect people and objects in a video with Amazon Rekognition.
This example shows you how to add preconditions to Amazon S3 requests.
Start the example by running the following at a command prompt:
python scenarios/conditional_requests/scenario.py
This example shows you how to do the following:
- Create an Amazon S3 bucket.
- Upload a test object.
- Attach multiple annotations to the object.
- Retrieve and list annotations with optional prefix filtering.
- Update an existing annotation.
- Delete annotations and verify removal.
- Clean up all resources.
Start the example by running the following at a command prompt:
python scenarios/object_annotations/scenario_object_annotations.py
This example shows you how to manage versioned S3 objects in batches with a Lambda function.
Start the example by running the following at a command prompt:
This example shows you how to upload or download large files to and from Amazon S3.
Start the example by running the following at a command prompt:
python file_transfer/file_transfer.py
This example shows you how to do the following:
- Create a versioned S3 bucket.
- Get all versions of an object.
- Roll an object back to a previous version.
- Delete and restore a versioned object.
- Permanently delete all versions of an object.
Start the example by running the following at a command prompt:
python s3_versioning/versioning.py
⚠ Running tests might result in charges to your AWS account.
To find instructions for running these tests, see the README
in the python folder.
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0