Interface DownloadDirectoryRequest.Builder
- All Superinterfaces:
Buildable
,CopyableBuilder<DownloadDirectoryRequest.Builder,
,DownloadDirectoryRequest> SdkBuilder<DownloadDirectoryRequest.Builder,
DownloadDirectoryRequest>
- Enclosing class:
DownloadDirectoryRequest
-
Method Summary
Modifier and TypeMethodDescriptionThe name of the bucket to download objects from.destination
(Path destination) Specifies the destination directory to which files should be downloaded.downloadFileRequestTransformer
(Consumer<DownloadFileRequest.Builder> downloadFileRequestTransformer) Specifies a function used to transform theDownloadFileRequest
s generated by thisDownloadDirectoryRequest
.filter
(DownloadFilter filter) Specifies a filter that will be used to evaluate which objects should be downloaded from the target directory.listObjectsV2RequestTransformer
(Consumer<ListObjectsV2Request.Builder> listObjectsV2RequestTransformer) Specifies a function used to transform theListObjectsV2Request
s generated by thisDownloadDirectoryRequest
.Methods inherited from interface software.amazon.awssdk.utils.builder.CopyableBuilder
copy
Methods inherited from interface software.amazon.awssdk.utils.builder.SdkBuilder
applyMutation, build
-
Method Details
-
destination
Specifies the destination directory to which files should be downloaded.- Parameters:
destination
- the destination directorÏy- Returns:
- This builder for method chaining.
-
bucket
The name of the bucket to download objects from.- Parameters:
bucket
- the bucket name- Returns:
- This builder for method chaining.
-
filter
Specifies a filter that will be used to evaluate which objects should be downloaded from the target directory.You can use a filter, for example, to only download objects of a given size, of a given file extension, of a given last-modified date, etc. See
DownloadFilter
for some ready-made implementations. MultipleDownloadFilter
s can be composed together via theand
andor
methods.By default, if no filter is specified, all objects will be downloaded.
- Parameters:
filter
- the filter- Returns:
- This builder for method chaining.
- See Also:
-
downloadFileRequestTransformer
DownloadDirectoryRequest.Builder downloadFileRequestTransformer(Consumer<DownloadFileRequest.Builder> downloadFileRequestTransformer) Specifies a function used to transform theDownloadFileRequest
s generated by thisDownloadDirectoryRequest
. The provided function is called once for each file that is downloaded, allowing you to modify the paths resolved by TransferManager on a per-file basis, modify the createdGetObjectRequest
before it is passed to S3, or configure aTransferRequestOverrideConfiguration
.The factory receives the
DownloadFileRequest
s created by Transfer Manager for each S3 Object in the S3 bucket being downloaded and returns a (potentially modified)DownloadFileRequest
.Usage Example:
// Add a LoggingTransferListener to every transfer within the download directory request DownloadDirectoryRequest request = DownloadDirectoryRequest.builder() .destination(Paths.get(".")) .bucket("bucket") .downloadFileRequestTransformer(request -> request.addTransferListener(LoggingTransferListener.create())) .build(); DownloadDirectoryTransfer downloadDirectory = transferManager.downloadDirectory(request); // Wait for the transfer to complete CompletedDownloadDirectory completedDownloadDirectory = downloadDirectory.completionFuture().join(); // Print out the failed downloads completedDownloadDirectory.failedDownloads().forEach(System.out::println);
- Parameters:
downloadFileRequestTransformer
- A transformer to use for modifying the file-level download requests before execution- Returns:
- This builder for method chaining
-
listObjectsV2RequestTransformer
DownloadDirectoryRequest.Builder listObjectsV2RequestTransformer(Consumer<ListObjectsV2Request.Builder> listObjectsV2RequestTransformer) Specifies a function used to transform theListObjectsV2Request
s generated by thisDownloadDirectoryRequest
. The provided function is called once, allowing you to modifyListObjectsV2Request
before it is passed to S3.The factory receives the
ListObjectsV2Request
s created by Transfer Manager and returns a (potentially modified)ListObjectsV2Request
.Usage Example:
DownloadDirectoryRequest request = DownloadDirectoryRequest.builder() .destination(Paths.get(".")) .bucket("bucket") .listObjectsV2RequestTransformer(request -> request.encodingType(newEncodingType)) .build(); DownloadDirectoryTransfer downloadDirectory = transferManager.downloadDirectory(request); // Wait for the transfer to complete CompletedDownloadDirectory completedDownloadDirectory = downloadDirectory.completionFuture().join(); // Print out the failed downloads completedDownloadDirectory.failedDownloads().forEach(System.out::println);
Prefix:
ListObjectsV2Request
'sprefix
specifies the key prefix for the virtual directory. If not provided, all subdirectories will be downloaded recursivelySee Organizing objects using prefixes
When a non-empty prefix is provided, the prefix is stripped from the directory structure of the files.
For example, assume that you have the following keys in your bucket:
- sample.jpg
- photos/2022/January/sample.jpg
- photos/2022/February/sample1.jpg
- photos/2022/February/sample2.jpg
- photos/2022/February/sample3.jpg
|- test |- 2022 |- January |- sample.jpg |- February |- sample1.jpg |- sample2.jpg |- sample3.jpg
Delimiter:
ListObjectsV2Request
'sdelimiter
specifies the delimiter that will be used to retrieve the objects within the provided bucket. A delimiter causes a list operation to roll up all the keys that share a common prefix into a single summary list result. It's null by default. For example, assume that you have the following keys in your bucket:- sample.jpg
- photos-2022-January-sample.jpg
- photos-2022-February-sample1.jpg
- photos-2022-February-sample2.jpg
- photos-2022-February-sample3.jpg
|- test |- sample.jpg |- photos |- 2022 |- January |- sample.jpg |- February |- sample1.jpg |- sample2.jpg |- sample3.jpg
- Parameters:
listObjectsV2RequestTransformer
- A transformer to use for modifying ListObjectsV2Request before execution- Returns:
- This builder for method chaining
-