Transfer acceleration examples
Amazon S3 Transfer Acceleration Examples
This section provides examples of how to enable Amazon S3 Transfer Acceleration on a bucket and use the acceleration endpoint for the enabled bucket. Some of the AWS SDK supported languages (for example, Java and .NET) use an accelerate endpoint client configuration flag so you don't need to explicitly set the endpoint for Transfer Acceleration to bucketname.s3-accelerate.amazonaws.com. For more information about Transfer Acceleration, see Amazon S3 Transfer Acceleration.
Topics
- Using the Amazon S3 Console
- Using Transfer Acceleration from the AWS Command Line Interface (AWS CLI)
- Using Transfer Acceleration from the AWS SDK for Java
- Using Transfer Acceleration from the AWS SDK for .NET
- Using Transfer Acceleration from the AWS SDK for JavaScript
- Using Transfer Acceleration from the AWS SDK for Python (Boto)
- Using Other AWS SDKs
Using the Amazon S3 Console
For information about enabling Transfer Acceleration on a bucket using the Amazon S3 console, see Enabling Transfer Acceleration in the Amazon Simple Storage Service Console User Guide.
Using Transfer Acceleration from the AWS Command Line Interface (AWS CLI)
This section provides examples of AWS CLI commands used for Transfer Acceleration. For instructions on setting up the AWS CLI, see Setting Up the AWS CLI.
Enabling Transfer Acceleration on a Bucket Using the AWS CLI
Use the AWS CLI put-bucket-accelerate-configuration command to enable or suspend Transfer Acceleration on a bucket. The following example sets Status=Enabled
to enable Transfer Acceleration on a bucket. You use Status=Suspended
to suspend Transfer Acceleration.
Example
Using the Transfer Acceleration from the AWS CLI
Setting the configuration value use_accelerate_endpoint
to true
in a profile in your AWS Config File will direct all Amazon S3 requests made by s3 and s3api AWS CLI commands to the accelerate endpoint: s3-accelerate.amazonaws.com
. Transfer Acceleration must be enabled on your bucket to use the accelerate endpoint.
All request are sent using the virtual style of bucket addressing:Â my-bucket.s3-accelerate.amazonaws.com
. Any ListBuckets
, CreateBucket
, and DeleteBucket
requests will not be sent to the accelerate endpoint as the endpoint does not support those operations. For more information about use_accelerate_endpoint
, see AWS CLI S3 Configuration.
The following example sets use_accelerate_endpoint
to true
in the default profile.
Example
If you want to use the accelerate endpoint for some AWS CLI commands but not others, you can use either one of the following two methods:
- You can use the accelerate endpoint per command by setting the
--endpoint-url
parameter tohttps://s3-accelerate.amazonaws.com
orhttp://s3-accelerate.amazonaws.com
for any s3 or s3api command. - You can setup separate profiles in your AWS Config File. For example, create one profile that sets
use_accelerate_endpoint
totrue
and a profile that does not setuse_accelerate_endpoint
. When you execute a command specify which profile you want to use, depending upon whether or not you want to use the accelerate endpoint.
AWS CLI Examples of Uploading an Object to a Bucket Enabled for Transfer Acceleration
The following example uploads a file to a bucket enabled for Transfer Acceleration by using the default profile that has been configured to use the accelerate endpoint.
Example
The following example uploads a file to a bucket enabled for Transfer Acceleration by using the --endpoint-url
parameter to specify the accelerate endpoint.
Example
Using Transfer Acceleration from the AWS SDK for Java
Example
The following example shows how to use an accelerate endpoint to upload an object to Amazon S3. The example does the following:
- Creates an
AmazonS3Client
that is configured to use accelerate endpoints. All buckets that the client accesses must have transfer acceleration enabled. - Enables transfer acceleration on a specified bucket. This step is necessary only if the bucket you specify doesn't already have transfer acceleration enabled.
- Verifies that transfer acceleration is enabled for the specified bucket.
- Uploads a new object to the specified bucket using the bucket's accelerate endpoint. For more information about using Transfer Acceleration, see Getting Started with Amazon S3 Transfer Acceleration. For instructions on creating and testing a working sample, see Testing the Amazon S3 Java Code Examples.
Using Transfer Acceleration from the AWS SDK for .NET
The following example shows how to use the AWS SDK for .NET to enable Transfer Acceleration on a bucket. For instructions on how to create and test a working sample, see Running the Amazon S3 .NET Code Examples.
Example
When uploading an object to a bucket that has Transfer Acceleration enabled, you specify using acceleration endpoint at the time of creating a client as shown:
Using Transfer Acceleration from the AWS SDK for JavaScript
For an example of enabling Transfer Acceleration by using the AWS SDK for JavaScript, see Calling the putBucketAccelerateConfiguration operation in the AWS SDK for JavaScript API Reference.
Using Transfer Acceleration from the AWS SDK for Python (Boto)
For an example of enabling Transfer Acceleration by using the SDK for Python, see put_bucket_accelerate_configuration in the AWS SDK for Python (Boto 3) API Reference.
Using Other AWS SDKs
For information about using other AWS SDKs, see Sample Code and Libraries.