Configure the Java-based S3 async client to use parallel transfers - AWS SDK for Java 2.x

Configure the Java-based S3 async client to use parallel transfers

Since version 2.27.5, the standard Java-based S3 async client supports automatic parallel transfers (multipart uploads and downloads). You configure support for parallel transfers when you create the Java-based S3 async client.

This section shows how to enable parallel transfers and how to customize the configuration.

Create an instance of S3AsyncClient

When you create an S3AsyncClient instance without calling any of the multipart* methods on the builder, parallel transfers are not enabled. Each of following statements create a Java-based S3 async client without support for multipart uploads and downloads.

Create without multipart support

import software.amazon.awssdk.auth.credentials.ProcessCredentialsProvider; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3.S3AsyncClient; S3AsyncClient s3Client = S3AsyncClient.create(); S3AsyncClient s3Client2 = S3AsyncClient.builder().build(); S3AsyncClient s3Client3 = S3AsyncClient.builder() .credentialsProvider(ProcessCredentialsProvider.builder().build()) .region(Region.EU_NORTH_1) .build();

Create with multipart support

To enable parallel transfers with default settings, call the multipartEnabled on the builder and pass in true as shown in the following example.

S3AsyncClient s3AsyncClient2 = S3AsyncClient.builder() .multipartEnabled(true) .build();

The default value is 8 MiB for thresholdInBytes and minimumPartSizeInBytes settings.

If you customize the multipart settings, parallel transfers are automatically enabled as shown in the following.

import software.amazon.awssdk.services.s3.S3AsyncClient; import static software.amazon.awssdk.transfer.s3.SizeConstant.MB; S3AsyncClient s3AsyncClient2 = S3AsyncClient.builder() .multipartConfiguration(b -> b .thresholdInBytes(16 * MB) .minimumPartSizeInBytes(10 * MB)) .build();