Migrate pre-signed URL downloads from AWS SDK for Java v1 to v2
Migrate your pre-signed URL download code to use asynchronous processing and access expanded download options in version 2. This topic shows how to migrate from version 1.x (v1) to version 2.x (v2) of the AWS SDK for Java. For information about v2 pre-signed URL download capabilities, see Work with Amazon S3 pre-signed URLs.
High-level changes
The following list summarizes the key differences between v1 and v2 for pre-signed URL downloads:
-
Package:
com.amazonaws.services.s3→software.amazon.awssdk.services.s3. -
Client class:
AmazonS3(synchronous) →S3AsyncClient(asynchronous). -
Architecture: Synchronous blocking calls → Asynchronous calls with
CompletableFuture. -
Multipart: Available only through Transfer Manager → Available directly on client with
multipartEnabled(true). -
Transfer Manager: File destination only → File, bytes, or custom transformer.
Changes in dependencies, packages, and class names
The following table shows the dependency and class name changes from v1 to v2.
| Change | v1 | v2 |
|---|---|---|
|
Maven dependencies |
|
|
| Package name | com.amazonaws.services.s3 |
software.amazon.awssdk.services.s3 |
| Class names | AmazonS3, TransferManager |
S3AsyncClient, S3TransferManager |
1
Latest
version
API changes
S3 client downloads
The following table compares v1 and v2 API calls for S3 client downloads.
| Use case | v1 | v2 |
|---|---|---|
| Create the client |
|
|
| Generate a pre-signed URL |
|
|
| Create the download request |
|
|
| Download to stream |
|
|
| Download to file |
|
|
| Download with range |
|
|
Transfer Manager downloads
The following table compares v1 and v2 API calls for Transfer Manager downloads.
| Use case | v1 | v2 |
|---|---|---|
| Create the Transfer Manager |
|
|
| Download |
|
|
For more information, see Download using a pre-signed URL.
Configuration changes
S3 client
The following table describes the S3 client configuration changes from v1 to v2.
| Setting | v1 | v2 |
|---|---|---|
| Multipart configuration | PresignedUrlDownloadConfig.withDownloadSizePerRequest(long) |
S3AsyncClient.builder().multipartConfiguration(c ->
c.minimumPartSizeInBytes(...)) |
| Custom headers | PresignedUrlDownloadRequest.putCustomRequestHeader(String,
String) |
Not supported. Only Range and If-Match can
be set at download time. |
Transfer Manager
The following table describes the Transfer Manager configuration changes from v1 to v2.
| Setting | v1 | v2 |
|---|---|---|
| Progress tracking | PresignedUrlDownloadConfig.withS3progressListener(...) |
PresignedDownloadFileRequest.builder().addTransferListener(...) |
| Resume on retry | PresignedUrlDownloadConfig.withResumeOnRetry(true) |
Not supported |
| Pause/Resume | Not supported | Not supported |
Note
The AWS CRT-based S3 client (S3AsyncClient.crtBuilder()) does not
currently support the pre-signed URL extension. Use
S3AsyncClient.builder().