Use {@link #builder()} to create a set of options.
@@ -42,6 +42,7 @@ public final class S3ClientConfiguration implements ToCopyableBuilder+ * Usage Example: + *
+ * {@code + * UploadDirectory uploadDirectory = + * transferManager.uploadDirectory(UploadDirectoryRequest.builder() + * .sourceDirectory(Paths.get(".")) + * .bucket("bucket") + * .prefix("prefix") + * .build()); + * // Wait for the transfer to complete + * uploadDirectory.completionFuture().join(); + * } + *+ * + * @param uploadDirectoryRequest the upload directory request + * @see #uploadDirectory(UploadDirectoryRequest) + */ + default UploadDirectory uploadDirectory(UploadDirectoryRequest uploadDirectoryRequest) { + throw new UnsupportedOperationException(); + } + + /** + * Upload the given directory to the S3 bucket under the given prefix. + * + *
+ * This is a convenience method that creates an instance of the {@link UploadDirectoryRequest} builder avoiding the + * need to create one manually via {@link UploadDirectoryRequest#builder()}. + * + *
+ * Usage Example: + *
+ * {@code + * UploadDirectory uploadDirectory = + * transferManager.uploadDirectory(b -> b.sourceDirectory(Paths.get(".")) + * .bucket("key") + * .prefix("prefix")); + * // Wait for the transfer to complete + * uploadDirectory.completionFuture().join(); + * } + *+ * @param requestBuilder the upload directory request builder + */ + default UploadDirectory uploadDirectory(Consumer
Use {@link #builder()} to create a set of options.
+ */ +@SdkPublicApi +@SdkPreviewApi +public final class UploadDirectoryConfiguration implements ToCopyableBuilder
+ * Default to false
+ *
+ * @param followSymbolicLinks whether to follow symbolic links
+ * @return This builder for method chaining.
+ */
+ Builder followSymbolicLinks(Boolean followSymbolicLinks);
+
+ /**
+ * Specify the maximum number of directory levels to traverse
+ * @param maxDepth the maximum number of directory levels
+ * @return This builder for method chaining.
+ */
+ Builder maxDepth(Integer maxDepth);
+
+ @Override
+ UploadDirectoryConfiguration build();
+ }
+
+ private static final class DefaultBuilder implements Builder {
+ private Boolean followSymbolicLinks;
+ private Integer maxDepth;
+ private Boolean recursive;
+
+ private DefaultBuilder(UploadDirectoryConfiguration configuration) {
+ this.followSymbolicLinks = configuration.followSymbolicLinks;
+ this.maxDepth = configuration.maxDepth;
+ this.recursive = configuration.recursive;
+ }
+
+ private DefaultBuilder() {
+ }
+
+ @Override
+ public DefaultBuilder recursive(Boolean recursive) {
+ this.recursive = recursive;
+ return this;
+ }
+
+ @Override
+ public DefaultBuilder followSymbolicLinks(Boolean followSymbolicLinks) {
+ this.followSymbolicLinks = followSymbolicLinks;
+ return this;
+ }
+
+ @Override
+ public DefaultBuilder maxDepth(Integer maxDepth) {
+ this.maxDepth = maxDepth;
+ return this;
+ }
+
+ @Override
+ public UploadDirectoryConfiguration build() {
+ return new UploadDirectoryConfiguration(this);
+ }
+
+ }
+}
diff --git a/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/UploadDirectoryRequest.java b/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/UploadDirectoryRequest.java
new file mode 100644
index 000000000000..d0ed8dca84d2
--- /dev/null
+++ b/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/UploadDirectoryRequest.java
@@ -0,0 +1,223 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package software.amazon.awssdk.transfer.s3;
+
+
+import java.nio.file.Path;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.Consumer;
+import software.amazon.awssdk.annotations.SdkPreviewApi;
+import software.amazon.awssdk.annotations.SdkPublicApi;
+import software.amazon.awssdk.utils.Validate;
+import software.amazon.awssdk.utils.builder.CopyableBuilder;
+import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
+
+/**
+ * Request object to upload a local directory to S3 using the Transfer Manager.
+ */
+@SdkPublicApi
+@SdkPreviewApi
+public final class UploadDirectoryRequest implements TransferRequest, ToCopyableBuilder
+ * The returned {@link 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 {@link CompletedUploadDirectory#failedUploads()}
+ * even when the future completes successfully. Failed single file uploads can be retried by calling
+ * {@link S3TransferManager#upload(UploadRequest)}
+ *
+ *
+ * The current user must have read access to all directories and files
*
*
* Usage Example:
@@ -174,19 +192,49 @@ default Upload upload(Consumer
+ * The returned {@link 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 {@link CompletedUploadDirectory#failedUploads()}
+ * even when the future completes successfully. Failed single file uploads can be retried by calling
+ * {@link S3TransferManager#upload(UploadRequest)}
+ *
+ *
+ * The current user must have read access to all directories and files
*
*
* This is a convenience method that creates an instance of the {@link UploadDirectoryRequest} builder avoiding the
@@ -200,13 +248,24 @@ default UploadDirectory uploadDirectory(UploadDirectoryRequest uploadDirectoryRe
* transferManager.uploadDirectory(b -> b.sourceDirectory(Paths.get("."))
* .bucket("key")
* .prefix("prefix"));
- * // Wait for the transfer to complete
- * uploadDirectory.completionFuture().join();
- * }
+ * // Print out the failed uploads
+ * completedUploadDirectory.failedUploads().forEach(System.out::println);
+ *
+ * // Retrying failed uploads if the exceptions are retryable
+ * List
+ * This is a convenience method that creates an instance of the {@link S3TransferManagerOverrideConfiguration} builder
+ * avoiding the need to create one manually via {@link S3TransferManagerOverrideConfiguration#builder()}.
+ *
+ * @param configuration the configuration to use
+ * @return Returns a reference to this object so that method calls can be chained together.
+ * @see #transferConfiguration(S3TransferManagerOverrideConfiguration)
+ */
+ default Builder transferConfiguration(Consumer
+ * All values are optional, and not specifying them will use default values provided bt the SDK.
+ *
+ * Use {@link #builder()} to create a set of options.
+ * Default to true
+ *
* @param recursive whether enable recursive upload
* @return This builder for method chaining.
*/
Builder recursive(Boolean recursive);
/**
- * Specify whether to follow Follow symbolic links when traverse the directory tree.
+ * Specify whether to follow symbolic links when traversing the file tree.
*
* Default to false
*
@@ -132,14 +136,19 @@ public interface Builder extends CopyableBuilder
* All values are optional, and not specifying them will use default values provided bt the SDK.
*
- * Use {@link #builder()} to create a set of options. Use {@link #builder()} to create a set of options.
+ * @see S3TransferManager.Builder#transferConfiguration(S3TransferManagerOverrideConfiguration)
*/
-
@SdkPublicApi
@SdkPreviewApi
public final class S3TransferManagerOverrideConfiguration implements
@@ -102,7 +102,8 @@ public static Builder builder() {
public interface Builder extends CopyableBuilder Use {@link #builder()} to create a set of options. Use {@link #builder()} to create a set of options.
+ * @see S3TransferManager#uploadDirectory(UploadDirectoryRequest)
*/
@SdkPublicApi
@SdkPreviewApi
@@ -47,6 +48,7 @@ public UploadDirectoryOverrideConfiguration(DefaultBuilder builder) {
/**
* @return whether to follow symbolic links
+ * @see Builder#followSymbolicLinks(Boolean)
*/
public Optional
+ * Failed single file uploads can be retried by calling {@link S3TransferManager#upload(UploadRequest)}
+ *
+ *
+ * This executor must be shut down by the user when it is ready to be disposed. The SDK will not close the executor
+ * when the s3 transfer manager is closed.
+ *
+ * @param executor the executor to use
* @return this builder for method chaining.
*/
Builder executor(Executor executor);
diff --git a/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/UploadDirectoryRequest.java b/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/UploadDirectoryRequest.java
index 856c2ca22ad6..3e29405cb4ae 100644
--- a/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/UploadDirectoryRequest.java
+++ b/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/UploadDirectoryRequest.java
@@ -54,6 +54,7 @@ public UploadDirectoryRequest(DefaultBuilder builder) {
* The source directory to upload
*
* @return the source directory
+ * @see Builder#sourceDirectory(Path)
*/
public Path sourceDirectory() {
return sourceDirectory;
@@ -63,6 +64,7 @@ public Path sourceDirectory() {
* The name of the bucket to upload objects to.
*
* @return bucket name
+ * @see Builder#bucket(String)
*/
public String bucket() {
return bucket;
@@ -70,17 +72,23 @@ public String bucket() {
/**
* @return the optional key prefix
+ * @see Builder#prefix(String)
*/
public Optional
+ * Note that the current user must have read access to all directories and files,
+ * otherwise {@link SecurityException} will be thrown.
*
* @param sourceDirectory the source directory
* @return This builder for method chaining.
+ * @see UploadDirectoryOverrideConfiguration
*/
Builder sourceDirectory(Path sourceDirectory);
diff --git a/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/UploadRequest.java b/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/UploadRequest.java
index 57d1ae13c277..c45162040a8c 100644
--- a/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/UploadRequest.java
+++ b/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/UploadRequest.java
@@ -32,6 +32,7 @@
/**
* Upload an object to S3 using {@link S3TransferManager}.
+ * @see S3TransferManager#upload(UploadRequest)
*/
@SdkPublicApi
@SdkPreviewApi
diff --git a/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultCompletedDownload.java b/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultCompletedDownload.java
deleted file mode 100644
index 46a9716f61bd..000000000000
--- a/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultCompletedDownload.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package software.amazon.awssdk.transfer.s3.internal;
-
-import software.amazon.awssdk.annotations.SdkInternalApi;
-import software.amazon.awssdk.services.s3.model.GetObjectResponse;
-import software.amazon.awssdk.transfer.s3.CompletedDownload;
-
-@SdkInternalApi
-public final class DefaultCompletedDownload implements CompletedDownload {
- private final GetObjectResponse response;
-
- private DefaultCompletedDownload(Builder builder) {
- this.response = builder.response;
- }
-
- @Override
- public GetObjectResponse response() {
- return response;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static final class Builder {
- private GetObjectResponse response;
-
- public Builder response(GetObjectResponse response) {
- this.response = response;
- return this;
- }
-
- public CompletedDownload build() {
- return new DefaultCompletedDownload(this);
- }
- }
-}
diff --git a/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultCompletedUpload.java b/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultCompletedUpload.java
deleted file mode 100644
index 0a7371706116..000000000000
--- a/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultCompletedUpload.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package software.amazon.awssdk.transfer.s3.internal;
-
-import software.amazon.awssdk.annotations.SdkInternalApi;
-import software.amazon.awssdk.services.s3.model.PutObjectResponse;
-import software.amazon.awssdk.transfer.s3.CompletedUpload;
-import software.amazon.awssdk.utils.ToString;
-import software.amazon.awssdk.utils.Validate;
-
-@SdkInternalApi
-public final class DefaultCompletedUpload implements CompletedUpload {
- private final PutObjectResponse response;
-
- private DefaultCompletedUpload(BuilderImpl builder) {
- this.response = Validate.paramNotNull(builder.response, "response");
- }
-
- @Override
- public PutObjectResponse response() {
- return response;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- DefaultCompletedUpload that = (DefaultCompletedUpload) o;
-
- return response.equals(that.response);
- }
-
- @Override
- public int hashCode() {
- return response.hashCode();
- }
-
- @Override
- public String toString() {
- return ToString.builder("CompletedUpload")
- .add("response", response)
- .build();
- }
-
- /**
- * Creates a default builder for {@link CompletedUpload}.
- */
- public static Builder builder() {
- return new DefaultCompletedUpload.BuilderImpl();
- }
-
- interface Builder {
- Builder response(PutObjectResponse response);
-
- CompletedUpload build();
- }
-
- private static class BuilderImpl implements Builder {
- private PutObjectResponse response;
-
- @Override
- public Builder response(PutObjectResponse response) {
- this.response = response;
- return this;
- }
-
- @Override
- public CompletedUpload build() {
- return new DefaultCompletedUpload(this);
- }
- }
-}
diff --git a/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultS3TransferManager.java b/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultS3TransferManager.java
index a66a4190c55e..16cf7f3d6c44 100644
--- a/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultS3TransferManager.java
+++ b/services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultS3TransferManager.java
@@ -16,6 +16,7 @@
package software.amazon.awssdk.transfer.s3.internal;
import java.nio.file.Files;
+import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;
import software.amazon.awssdk.annotations.SdkInternalApi;
@@ -98,9 +99,9 @@ public Upload upload(UploadRequest uploadRequest) {
CompletableFuture
+ * {@code
+ * // Retrying failed uploads if the exception is retryable
+ * List
+ *
* @return a list of failed uploads
*/
public Collection