@ThreadSafe public interface S3TransferManager extends SdkAutoCloseable
| 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. |
default Copy |
copy(Consumer<CopyRequest.Builder> copyRequestBuilder)
This is a convenience method that creates an instance of the
CopyRequest builder, avoiding the need to create one
manually via CopyRequest.builder(). |
default Copy |
copy(CopyRequest copyRequest)
Creates a copy of an object that is already stored in S3 in the same region.
|
static S3TransferManager |
create()
Create an
S3TransferManager using the default values. |
default <ResultT> Download<ResultT> |
download(DownloadRequest<ResultT> downloadRequest)
Downloads an object identified by the bucket and key from S3 through the given
AsyncResponseTransformer. |
default DirectoryDownload |
downloadDirectory(Consumer<DownloadDirectoryRequest.Builder> requestBuilder)
This is a convenience method that creates an instance of the
DownloadDirectoryRequest builder, avoiding the need to
create one manually via DownloadDirectoryRequest.builder(). |
default DirectoryDownload |
downloadDirectory(DownloadDirectoryRequest downloadDirectoryRequest)
Downloads all objects under a bucket to the provided directory.
|
default FileDownload |
downloadFile(Consumer<DownloadFileRequest.Builder> request)
This is a convenience method that creates an instance of the
DownloadFileRequest builder, avoiding the need to
create one manually via DownloadFileRequest.builder(). |
default FileDownload |
downloadFile(DownloadFileRequest downloadRequest)
Downloads an object identified by the bucket and key from S3 to a local file.
|
default FileDownload |
resumeDownloadFile(Consumer<ResumableFileDownload.Builder> resumableFileDownload)
This is a convenience method that creates an instance of the
ResumableFileDownload builder, avoiding the need to
create one manually via ResumableFileDownload.builder(). |
default FileDownload |
resumeDownloadFile(ResumableFileDownload resumableFileDownload)
Resumes a downloadFile operation.
|
default FileUpload |
resumeUploadFile(Consumer<ResumableFileUpload.Builder> resumableFileUpload)
This is a convenience method that creates an instance of the
ResumableFileUpload builder, avoiding the need to
create one manually via ResumableFileUpload.builder(). |
default FileUpload |
resumeUploadFile(ResumableFileUpload resumableFileUpload)
Resumes uploadFile operation.
|
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(). |
default Upload |
upload(UploadRequest uploadRequest)
Uploads the given
AsyncRequestBody to an object in S3. |
default DirectoryUpload |
uploadDirectory(Consumer<UploadDirectoryRequest.Builder> requestBuilder)
This is a convenience method that creates an instance of the
UploadDirectoryRequest builder, avoiding the need to
create one manually via UploadDirectoryRequest.builder(). |
default DirectoryUpload |
uploadDirectory(UploadDirectoryRequest uploadDirectoryRequest)
Uploads all files under the given directory to the provided S3 bucket.
|
default FileUpload |
uploadFile(Consumer<UploadFileRequest.Builder> request)
This is a convenience method that creates an instance of the
UploadFileRequest builder, avoiding the need to create
one manually via UploadFileRequest.builder(). |
default FileUpload |
uploadFile(UploadFileRequest uploadFileRequest)
Uploads a local file to an object in S3.
|
closedefault FileDownload downloadFile(DownloadFileRequest downloadRequest)
download(DownloadRequest) instead.
The SDK will create a new file if the provided one doesn't exist. The default permission for the new file depends on the file system and platform. Users can configure the permission on the file using Java API by themselves. If the file already exists, the SDK will replace it. In the event of an error, the SDK will NOT attempt to delete the file, leaving it as-is.
Users can monitor the progress of the transfer by attaching a TransferListener. The provided
LoggingTransferListener logs a basic progress bar; users can also implement their own listeners.
Usage Example:
downloadFile(Consumer),
download(DownloadRequest)default FileDownload downloadFile(Consumer<DownloadFileRequest.Builder> request)
DownloadFileRequest builder, avoiding the need to
create one manually via DownloadFileRequest.builder().downloadFile(DownloadFileRequest)default FileDownload resumeDownloadFile(ResumableFileDownload resumableFileDownload)
If it is determined that the source S3 object or the destination file has be modified since the last pause, the SDK
will download the object from the beginning as if it is a new DownloadFileRequest.
Usage Example:
resumableFileDownload - the download to resume.FileDownload object to use to check the state of the download.downloadFile(DownloadFileRequest),
FileDownload.pause()default FileDownload resumeDownloadFile(Consumer<ResumableFileDownload.Builder> resumableFileDownload)
ResumableFileDownload builder, avoiding the need to
create one manually via ResumableFileDownload.builder().default <ResultT> Download<ResultT> download(DownloadRequest<ResultT> downloadRequest)
AsyncResponseTransformer. For
downloading to a file, you may use downloadFile(DownloadFileRequest) instead.
Users can monitor the progress of the transfer by attaching a TransferListener. The provided
LoggingTransferListener logs a basic progress bar; users can also implement their own listeners.
Usage Example (this example buffers the entire object in memory and is not suitable for large objects):
See the static factory methods available in AsyncResponseTransformer for other use cases.
ResultT - The type of data the AsyncResponseTransformer producesdownloadRequest - the download request, containing a GetObjectRequest and AsyncResponseTransformerDownload that can be used to track the ongoing transferdownloadFile(DownloadFileRequest)default FileUpload uploadFile(UploadFileRequest uploadFileRequest)
upload(UploadRequest) instead.
Users can monitor the progress of the transfer by attaching a TransferListener. The provided
LoggingTransferListener logs a basic progress bar; users can also implement their own listeners.
Upload a local file to an object in S3. For non-file-based uploads, you may use upload(UploadRequest) instead.
Usage Example:
uploadFile(Consumer),
upload(UploadRequest)default FileUpload uploadFile(Consumer<UploadFileRequest.Builder> request)
UploadFileRequest builder, avoiding the need to create
one manually via UploadFileRequest.builder().uploadFile(UploadFileRequest)default FileUpload resumeUploadFile(ResumableFileUpload resumableFileUpload)
ResumableFileUpload. The SDK will skip the data that has already been upload since the last pause
and only upload the remaining data from the source file.
If it is determined that the source file has be modified since the last pause, the SDK will upload the object from the
beginning as if it is a new UploadFileRequest.
Usage Example:
resumableFileUpload - the upload to resume.FileUpload object to use to check the state of the download.uploadFile(UploadFileRequest),
FileUpload.pause()default FileUpload resumeUploadFile(Consumer<ResumableFileUpload.Builder> resumableFileUpload)
ResumableFileUpload builder, avoiding the need to
create one manually via ResumableFileUpload.builder().resumeUploadFile(ResumableFileUpload)default Upload upload(UploadRequest uploadRequest)
AsyncRequestBody to an object in S3. For file-based uploads, you may use
uploadFile(UploadFileRequest) instead.
Users can monitor the progress of the transfer by attaching a TransferListener. The provided
LoggingTransferListener logs a basic progress bar; users can also implement their own listeners.
Usage Example:
See the static factory methods available in AsyncRequestBody for other use cases.
uploadRequest - the upload request, containing a PutObjectRequest and AsyncRequestBodyUpload that can be used to track the ongoing transferupload(Consumer),
uploadFile(UploadFileRequest)default Upload upload(Consumer<UploadRequest.Builder> request)
UploadRequest builder, avoiding the need to create one
manually via UploadRequest.builder().upload(UploadRequest)default DirectoryUpload uploadDirectory(UploadDirectoryRequest uploadDirectoryRequest)
UploadDirectoryRequest. By default, all subdirectories will be uploaded
recursively, and symbolic links are not followed automatically.
This behavior can be configured in at request level via
UploadDirectoryRequest.Builder#followSymbolicLinks(Boolean) or
client level via S3TransferManager.Builder.uploadDirectoryFollowSymbolicLinks(Boolean)
Note that request-level configuration takes precedence over client-level configuration.
By default, the prefix is an empty string and the delimiter is "/". Assume you have a local
directory "/test" with the following structure:
|- test
|- sample.jpg
|- photos
|- 2022
|- January
|- sample.jpg
|- February
|- sample1.jpg
|- sample2.jpg
|- sample3.jpg
Give a request to upload directory "/test" to an S3 bucket, the target bucket will have the following
S3 objects:
The returned CompletableFuture only completes exceptionally if the request cannot be attempted as a whole (the
source directory provided does not exist for example). The future completes successfully for partial successful
requests, i.e., there might be failed uploads in the successfully completed response. As a result,
you should check for errors in the response via CompletedDirectoryUpload.failedTransfers()
even when the future completes successfully.
The current user must have read access to all directories and files.
Usage Example:
uploadDirectoryRequest - the upload directory requestuploadDirectory(Consumer)default DirectoryUpload uploadDirectory(Consumer<UploadDirectoryRequest.Builder> requestBuilder)
UploadDirectoryRequest builder, avoiding the need to
create one manually via UploadDirectoryRequest.builder().uploadDirectory(UploadDirectoryRequest)default DirectoryDownload downloadDirectory(DownloadDirectoryRequest downloadDirectoryRequest)
DownloadDirectoryRequest.listObjectsRequestTransformer() and/or
a DownloadDirectoryRequest.filter() in DownloadDirectoryRequest to
limit the S3 objects to download.
The downloaded directory structure will match with the provided S3 virtual bucket. For example, assume that you have the following keys in your bucket:
|- test
|- sample.jpg
|- photos
|- 2022
|- January
|- sample.jpg
|- February
|- sample1.jpg
|- sample2.jpg
|- sample3.jpg
The returned CompletableFuture only completes exceptionally if the request cannot be attempted as a whole (the
downloadDirectoryRequest is invalid for example). The future completes successfully for partial successful
requests, i.e., there might be failed downloads in a successfully completed response. As a result, you should check for
errors in the response via CompletedDirectoryDownload.failedTransfers() even when the future completes
successfully.
The SDK will create the destination directory if it does not already exist. If a specific file already exists, the existing content will be replaced with the corresponding S3 object content.
The current user must have write access to all directories and files
Usage Example:
downloadDirectoryRequest - the download directory requestdownloadDirectory(Consumer)default DirectoryDownload downloadDirectory(Consumer<DownloadDirectoryRequest.Builder> requestBuilder)
DownloadDirectoryRequest builder, avoiding the need to
create one manually via DownloadDirectoryRequest.builder().default Copy copy(CopyRequest copyRequest)
Depending on the underlying S3Client, S3TransferManager may intelligently use plain CopyObjectRequests
for smaller objects, and multiple parallel UploadPartCopyRequests for larger objects. If multipart copy is
supported by the underlying S3Client, this behavior can be configured via
S3CrtAsyncClientBuilder.minimumPartSizeInBytes(Long). Note that for multipart copy request, existing metadata
stored in the source object is NOT copied to the destination object; if required, you can retrieve the metadata from the
source object and set it explicitly in the @link CopyObjectRequest.Builder#metadata(Map)}.
While this API supports TransferListeners, they will not receive bytesTransferred callback-updates due to
the way the CopyObjectRequest API behaves. When copying an object, S3 performs the byte copying on your behalf
while keeping the connection alive. The progress of the copy is not known until it fully completes and S3 sends a response
describing the outcome.
Usage Example:
copyRequest - the copy request, containing a CopyObjectRequestCopy that can be used to track the ongoing transfercopy(Consumer)default Copy copy(Consumer<CopyRequest.Builder> copyRequestBuilder)
CopyRequest builder, avoiding the need to create one
manually via CopyRequest.builder().copy(CopyRequest)static S3TransferManager create()
S3TransferManager using the default values.
The type of S3AsyncClient used depends on if AWS Common Runtime (CRT) library
software.amazon.awssdk.crt:crt is on the classpath. If CRT is available, a CRT-based S3 client will be created
(S3AsyncClient.crtCreate()). Otherwise, a standard S3 client(S3AsyncClient.create()) will be created. Note
that only CRT-based S3 client supports parallel transfer for now, so it's recommended to add CRT as a dependency.
static S3TransferManager.Builder builder()
S3TransferManager.Copyright © 2023. All rights reserved.