Working with Amazon S3 - AWS SDK for Java 2.x

You can now use the Amazon S3 Transfer Manager (Developer Preview) in the AWS SDK for Java 2.x for accelerated file transfers. Give it a try and let us know what you think!

Working with Amazon S3

This section provides examples of programming with Amazon Simple Storage Service (S3) using the AWS SDK for Java 2.x.

The following examples include only the code needed to demonstrate each technique. The complete example code is available on GitHub. From there, you can download a single source file or clone the repository locally to get all the examples to build and run.


From version 2.18.x and onward, the AWS SDK for Java 2.x uses virtual host-style addressing when including an endpoint override, as long as the bucket name is a valid DNS label.

Call the forcePathStyle method with true in your client builder to force the client to use path-style addressing for buckets.

The following example shows a service client configured with an endpoint override and using path-style addressing.

S3Client client = S3Client.builder() .region(Region.US_WEST_2) .endpointOverride(URI.create("")) .forcePathStyle(true) .build();