Class S3Utils


  • public class S3Utils
    extends Object
    AWS S3 utilities.
    Since:
    10.1
    • Method Detail

      • processSlices

        public static void processSlices​(long slice,
                                         long length,
                                         S3Utils.SliceConsumer consumer)
        Calls the consumer on all slices.
        Parameters:
        slice - the slice size
        length - the total length
        consumer - the slice consumer
      • copyFile

        @Deprecated
        public static com.amazonaws.services.s3.model.ObjectMetadata copyFile​(com.amazonaws.services.s3.AmazonS3 amazonS3,
                                                                              com.amazonaws.services.s3.model.ObjectMetadata objectMetadata,
                                                                              String sourceBucket,
                                                                              String sourceKey,
                                                                              String targetBucket,
                                                                              String targetKey,
                                                                              String targetSSEAlgorithm,
                                                                              boolean deleteSource)
        Deprecated.
        since 11.2, use TransferManager.copy(java.lang.String, java.lang.String, java.lang.String, java.lang.String) instead
        Copies a file, using multipart upload if needed.
        Parameters:
        amazonS3 - the S3 client
        objectMetadata - the metadata of the object being copied
        sourceBucket - the source bucket
        sourceKey - the source key
        targetBucket - the target bucket
        targetKey - the target key
        targetSSEAlgorithm - the target SSE Algorithm to use, or null
        deleteSource - whether to delete the source object if the copy is successful
        Since:
        11.1
      • copyFileMultipart

        @Deprecated
        public static com.amazonaws.services.s3.model.ObjectMetadata copyFileMultipart​(com.amazonaws.services.s3.AmazonS3 amazonS3,
                                                                                       com.amazonaws.services.s3.model.ObjectMetadata objectMetadata,
                                                                                       String sourceBucket,
                                                                                       String sourceKey,
                                                                                       String targetBucket,
                                                                                       String targetKey,
                                                                                       boolean deleteSource)
        Copies a file using multipart upload.
        Parameters:
        amazonS3 - the S3 client
        objectMetadata - the metadata of the object being copied
        sourceBucket - the source bucket
        sourceKey - the source key
        targetBucket - the target bucket
        targetKey - the target key
        deleteSource - whether to delete the source object if the copy is successful
      • copyFileMultipart

        @Deprecated
        public static com.amazonaws.services.s3.model.ObjectMetadata copyFileMultipart​(com.amazonaws.services.s3.AmazonS3 amazonS3,
                                                                                       com.amazonaws.services.s3.model.ObjectMetadata objectMetadata,
                                                                                       String sourceBucket,
                                                                                       String sourceKey,
                                                                                       String targetBucket,
                                                                                       String targetKey,
                                                                                       String targetSSEAlgorithm,
                                                                                       boolean deleteSource)
        Deprecated.
        since 11.2, use TransferManager.copy(java.lang.String, java.lang.String, java.lang.String, java.lang.String) instead
        Copies a file using multipart upload.
        Parameters:
        amazonS3 - the S3 client
        objectMetadata - the metadata of the object being copied
        sourceBucket - the source bucket
        sourceKey - the source key
        targetBucket - the target bucket
        targetKey - the target key
        targetSSEAlgorithm - the target SSE Algorithm to use, or null
        deleteSource - whether to delete the source object if the copy is successful
        Since:
        11.1
      • responsesToETags

        protected static List<com.amazonaws.services.s3.model.PartETag> responsesToETags​(List<com.amazonaws.services.s3.model.CopyPartResult> responses)
      • copyFileNonMultipart

        @Deprecated
        public static com.amazonaws.services.s3.model.ObjectMetadata copyFileNonMultipart​(com.amazonaws.services.s3.AmazonS3 amazonS3,
                                                                                          com.amazonaws.services.s3.model.ObjectMetadata objectMetadata,
                                                                                          String sourceBucket,
                                                                                          String sourceKey,
                                                                                          String targetBucket,
                                                                                          String targetKey,
                                                                                          String targetSSEAlgorithm,
                                                                                          boolean deleteSource)
        Deprecated.
        since 11.2, use TransferManager.copy(java.lang.String, java.lang.String, java.lang.String, java.lang.String) instead
        Copies a file without using multipart upload.
        Parameters:
        amazonS3 - the S3 client
        objectMetadata - the metadata of the object being copied
        sourceBucket - the source bucket
        sourceKey - the source key
        targetBucket - the target bucket
        targetKey - the target key
        targetSSEAlgorithm - the target SSE Algorithm to use, or null
        deleteSource - whether to delete the source object if the copy is successful
        Since:
        11.1
      • getAWSCredentialsProvider

        public static com.amazonaws.auth.AWSCredentialsProvider getAWSCredentialsProvider​(String accessKeyId,
                                                                                          String secretKey,
                                                                                          String sessionToken)
        Gets the credentials providers for the given AWS key and secret.
        Parameters:
        accessKeyId - the AWS access key id
        secretKey - the secret key
        sessionToken - the session token (optional)
        Since:
        10.10