public interface S3TransferManager extends SdkAutoCloseable
// Create using all default configuration values
S3TransferManager transferManager = S3TransferManager.create();
// If you wish to configure settings, we recommend using the builder instead:
S3TransferManager transferManager =
S3TransferManager.builder()
.s3ClientConfiguration(b -> b.credentialsProvider(credentialProvider)
.region(Region.US_WEST_2)
.targetThroughputInGbps(20.0)
.minimumPartSizeInBytes(10 * MB))
.build();
// Download an S3 object to a file
Download download =
transferManager.download(b -> b.destination(Paths.get("myFile.txt"))
.getObjectRequest(r -> r.bucket("bucket")
.key("key")));
download.completionFuture().join();
// Upload a file to S3
Upload upload = transferManager.upload(b -> b.source(Paths.get("myFile.txt"))
.putObjectRequest(r -> r.bucket("bucket")
.key("key")));
upload.completionFuture().join();
| Modifier and Type | Interface and Description |
|---|---|
static interface |
S3TransferManager.Builder
The builder definition for a
S3TransferManager. |
| Modifier and Type | Method and Description |
|---|---|
static S3TransferManager.Builder |
builder()
Creates a default builder for
S3TransferManager. |
static S3TransferManager |
create()
Create an
S3TransferManager using the default values. |
default Download |
download(Consumer<DownloadRequest.Builder> request)
Download an object identified by the bucket and key from S3 to the given
file.
|
default Download |
download(DownloadRequest downloadRequest)
Download an object identified by the bucket and key from S3 to the given
file.
|
default Upload |
upload(Consumer<UploadRequest.Builder> request)
Upload a file to S3.
|
default Upload |
upload(UploadRequest uploadRequest)
Upload a file to S3.
|
closedefault Download download(DownloadRequest downloadRequest)
Usage Example:
// Initiate the transfer
Download download =
transferManager.download(DownloadRequest.builder()
.destination(Paths.get("myFile.txt"))
.getObjectRequest(GetObjectRequest.builder()
.bucket("bucket")
.key("key")
.build())
.build());
// Wait for the transfer to complete
download.completionFuture().join();
download(Consumer)default Download download(Consumer<DownloadRequest.Builder> request)
This is a convenience method that creates an instance of the DownloadRequest builder avoiding the
need to create one manually via DownloadRequest.builder().
Usage Example:
// Initiate the transfer
Download download =
transferManager.download(b -> b.destination(Paths.get("myFile.txt"))
.getObjectRequest(r -> r.bucket("bucket")
.key("key")));
// Wait for the transfer to complete
download.completionFuture().join();
download(DownloadRequest)default Upload upload(UploadRequest uploadRequest)
Usage Example:
Upload upload =
transferManager.upload(UploadRequest.builder()
.source(Paths.get("myFile.txt"))
.putObjectRequest(PutObjectRequest.builder()
.bucket("bucket")
.key("key")
.build())
.build());
// Wait for the transfer to complete
upload.completionFuture().join();
default Upload upload(Consumer<UploadRequest.Builder> request)
This is a convenience method that creates an instance of the UploadRequest builder avoiding the
need to create one manually via UploadRequest.builder().
Usage Example:
Upload upload =
transferManager.upload(b -> b.putObjectRequest(req -> req.bucket("bucket")
.key("key"))
.source(Paths.get("myFile.txt")));
// Wait for the transfer to complete
upload.completionFuture().join();
static S3TransferManager create()
S3TransferManager using the default values.static S3TransferManager.Builder builder()
S3TransferManager.Copyright © 2021. All rights reserved.