Interface UploadDirectoryRequest.Builder

All Superinterfaces:
Buildable, CopyableBuilder<UploadDirectoryRequest.Builder,UploadDirectoryRequest>, SdkBuilder<UploadDirectoryRequest.Builder,UploadDirectoryRequest>
Enclosing class:
UploadDirectoryRequest

public static interface UploadDirectoryRequest.Builder extends CopyableBuilder<UploadDirectoryRequest.Builder,UploadDirectoryRequest>
  • Method Details

    • source

      Specifies the source directory to upload. The source directory must exist. Fle wildcards are not supported and treated literally. Hidden files/directories are visited.

      Note that the current user must have read access to all directories and files, otherwise SecurityException will be thrown.

      Parameters:
      source - the source directory
      Returns:
      This builder for method chaining.
    • bucket

      The name of the bucket to upload objects to.
      Parameters:
      bucket - the bucket name
      Returns:
      This builder for method chaining.
    • s3Prefix

      Specifies the key prefix to use for the objects. If not provided, files will be uploaded to the root of the bucket

      See Organizing objects using prefixes

      Note: if the provided prefix ends with the same string as delimiter, it will get "normalized" when generating the key name. For example, assuming the prefix provided is "foo/" and the delimiter is "/" and the source directory has the following structure:

       |- test
           |- obj1.txt
           |- obj2.txt
       
      the object keys will be "foo/obj1.txt" and "foo/obj2.txt" as apposed to "foo//obj1.txt" and "foo//obj2.txt"
      Parameters:
      s3Prefix - the key prefix
      Returns:
      This builder for method chaining.
      See Also:
    • s3Delimiter

      UploadDirectoryRequest.Builder s3Delimiter(String s3Delimiter)
      Specifies the delimiter. A delimiter causes a list operation to roll up all the keys that share a common prefix into a single summary list result. If not provided, "/" will be used. See Organizing objects using prefixes

      Note: if the provided prefix ends with the same string as delimiter, it will get "normalized" when generating the key name. For example, assuming the prefix provided is "foo/" and the delimiter is "/" and the source directory has the following structure:

       |- test
           |- obj1.txt
           |- obj2.txt
       
      the object keys will be "foo/obj1.txt" and "foo/obj2.txt" as apposed to "foo//obj1.txt" and "foo//obj2.txt"
      Parameters:
      s3Delimiter - the delimiter
      Returns:
      This builder for method chaining.
      See Also:
    • followSymbolicLinks

      UploadDirectoryRequest.Builder followSymbolicLinks(Boolean followSymbolicLinks)
      Specifies whether to follow symbolic links when traversing the file tree in S3TransferManager.downloadDirectory(software.amazon.awssdk.transfer.s3.model.DownloadDirectoryRequest) operation

      Default to false

      Parameters:
      followSymbolicLinks - whether to follow symbolic links
      Returns:
      This builder for method chaining.
    • maxDepth

      Specifies the maximum number of levels of directories to visit. Must be positive. 1 means only the files directly within the provided source directory are visited.

      Default to Integer.MAX_VALUE

      Parameters:
      maxDepth - the maximum number of directory levels to visit
      Returns:
      This builder for method chaining.
    • uploadFileRequestTransformer

      UploadDirectoryRequest.Builder uploadFileRequestTransformer(Consumer<UploadFileRequest.Builder> uploadFileRequestTransformer)
      Specifies a function used to transform the UploadFileRequests generated by this UploadDirectoryRequest. The provided function is called once for each file that is uploaded, allowing you to modify the paths resolved by TransferManager on a per-file basis, modify the created PutObjectRequest before it is passed to S3, or configure a TransferRequestOverrideConfiguration.

      The factory receives the UploadFileRequests created by Transfer Manager for each file in the directory being uploaded, and returns a (potentially modified) UploadFileRequest.

      Usage Example:

       
       // Add a LoggingTransferListener to every transfer within the upload directory request
      
       UploadDirectoryOverrideConfiguration directoryUploadConfiguration =
           UploadDirectoryOverrideConfiguration.builder()
               .uploadFileRequestTransformer(request -> request.addTransferListener(LoggingTransferListener.create())
               .build();
      
       UploadDirectoryRequest request =
           UploadDirectoryRequest.builder()
               .source(Paths.get("."))
               .bucket("bucket")
               .prefix("prefix")
               .overrideConfiguration(directoryUploadConfiguration)
               .build()
      
       UploadDirectoryTransfer uploadDirectory = transferManager.uploadDirectory(request);
      
       // Wait for the transfer to complete
       CompletedUploadDirectory completedUploadDirectory = uploadDirectory.completionFuture().join();
      
       // Print out the failed uploads
       completedUploadDirectory.failedUploads().forEach(System.out::println);
       
       
      Parameters:
      uploadFileRequestTransformer - A transformer to use for modifying the file-level upload requests before execution
      Returns:
      This builder for method chaining
    • build

      Description copied from interface: SdkBuilder
      An immutable object that is created from the properties that have been set on the builder.
      Specified by:
      build in interface Buildable
      Specified by:
      build in interface SdkBuilder<UploadDirectoryRequest.Builder,UploadDirectoryRequest>
      Returns:
      an instance of T