public final class DefaultS3TransferManager extends Object implements S3TransferManager
S3TransferManager.Builder| Constructor and Description |
|---|
DefaultS3TransferManager(software.amazon.awssdk.transfer.s3.internal.DefaultS3TransferManager.DefaultBuilder tmBuilder) |
| Modifier and Type | Method and Description |
|---|---|
static S3TransferManager.Builder |
builder()
Creates a default builder for
S3TransferManager. |
void |
close() |
Copy |
copy(CopyRequest copyRequest)
Creates a copy of an object that is already stored in S3 in the same region.
|
<ResultT> Download<ResultT> |
download(DownloadRequest<ResultT> downloadRequest)
Downloads an object identified by the bucket and key from S3 through the given
AsyncResponseTransformer. |
DirectoryDownload |
downloadDirectory(DownloadDirectoryRequest downloadDirectoryRequest)
Downloads all objects under a bucket to the provided directory.
|
FileDownload |
downloadFile(DownloadFileRequest downloadRequest)
Downloads an object identified by the bucket and key from S3 to a local file.
|
FileDownload |
resumeDownloadFile(ResumableFileDownload resumableFileDownload)
Resumes a downloadFile operation.
|
FileUpload |
resumeUploadFile(ResumableFileUpload resumableFileUpload)
Resumes uploadFile operation.
|
Upload |
upload(UploadRequest uploadRequest)
Uploads the given
AsyncRequestBody to an object in S3. |
DirectoryUpload |
uploadDirectory(UploadDirectoryRequest uploadDirectoryRequest)
Uploads all files under the given directory to the provided S3 bucket.
|
FileUpload |
uploadFile(UploadFileRequest uploadFileRequest)
Uploads a local file to an object in S3.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcopy, create, downloadDirectory, downloadFile, resumeDownloadFile, resumeUploadFile, upload, uploadDirectory, uploadFilepublic DefaultS3TransferManager(software.amazon.awssdk.transfer.s3.internal.DefaultS3TransferManager.DefaultBuilder tmBuilder)
public Upload upload(UploadRequest uploadRequest)
S3TransferManagerAsyncRequestBody to an object in S3. For file-based uploads, you may use
S3TransferManager.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.
upload in interface S3TransferManageruploadRequest - the upload request, containing a PutObjectRequest and AsyncRequestBodyUpload that can be used to track the ongoing transferS3TransferManager.upload(Consumer),
S3TransferManager.uploadFile(UploadFileRequest)public FileUpload uploadFile(UploadFileRequest uploadFileRequest)
S3TransferManagerS3TransferManager.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 S3TransferManager.upload(UploadRequest) instead.
Usage Example:
uploadFile in interface S3TransferManagerS3TransferManager.uploadFile(Consumer),
S3TransferManager.upload(UploadRequest)public FileUpload resumeUploadFile(ResumableFileUpload resumableFileUpload)
S3TransferManagerResumableFileUpload. 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:
resumeUploadFile in interface S3TransferManagerresumableFileUpload - the upload to resume.FileUpload object to use to check the state of the download.S3TransferManager.uploadFile(UploadFileRequest),
FileUpload.pause()public DirectoryUpload uploadDirectory(UploadDirectoryRequest uploadDirectoryRequest)
S3TransferManagerUploadDirectoryRequest. 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:
uploadDirectory in interface S3TransferManageruploadDirectoryRequest - the upload directory requestS3TransferManager.uploadDirectory(Consumer)public <ResultT> Download<ResultT> download(DownloadRequest<ResultT> downloadRequest)
S3TransferManagerAsyncResponseTransformer. For
downloading to a file, you may use S3TransferManager.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.
download in interface S3TransferManagerResultT - The type of data the AsyncResponseTransformer producesdownloadRequest - the download request, containing a GetObjectRequest and AsyncResponseTransformerDownload that can be used to track the ongoing transferS3TransferManager.downloadFile(DownloadFileRequest)public FileDownload downloadFile(DownloadFileRequest downloadRequest)
S3TransferManagerS3TransferManager.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 in interface S3TransferManagerS3TransferManager.downloadFile(Consumer),
S3TransferManager.download(DownloadRequest)public FileDownload resumeDownloadFile(ResumableFileDownload resumableFileDownload)
S3TransferManager
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:
resumeDownloadFile in interface S3TransferManagerresumableFileDownload - the download to resume.FileDownload object to use to check the state of the download.S3TransferManager.downloadFile(DownloadFileRequest),
FileDownload.pause()public DirectoryDownload downloadDirectory(DownloadDirectoryRequest downloadDirectoryRequest)
S3TransferManagerDownloadDirectoryRequest.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:
downloadDirectory in interface S3TransferManagerdownloadDirectoryRequest - the download directory requestS3TransferManager.downloadDirectory(Consumer)public Copy copy(CopyRequest copyRequest)
S3TransferManager
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:
copy in interface S3TransferManagercopyRequest - the copy request, containing a CopyObjectRequestCopy that can be used to track the ongoing transferS3TransferManager.copy(Consumer)public void close()
close in interface AutoCloseableclose in interface SdkAutoCloseablepublic static S3TransferManager.Builder builder()
S3TransferManagerS3TransferManager.builder in interface S3TransferManagerCopyright © 2023. All rights reserved.