Package org.craftercms.commons.aws
Class AwsUtils
java.lang.Object
org.craftercms.commons.aws.AwsUtils
Provides utility methods for AWS services
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic software.amazon.awssdk.transfer.s3.S3TransferManagerbuildTransferManager(software.amazon.awssdk.services.s3.S3AsyncClient client) Builds theS3TransferManagerusing the sharedExecutorServicestatic software.amazon.awssdk.transfer.s3.S3TransferManagerbuildTransferManager(software.amazon.awssdk.services.s3.S3AsyncClient client, ThreadPoolExecutor threadPoolExecutor) Builds theS3TransferManagerusing the providedThreadPoolExecutorstatic voidcopyObjects(software.amazon.awssdk.services.s3.S3AsyncClient client, ThreadPoolExecutor threadPoolExecutor, String sourceBucket, String sourceBaseKey, String targetBucket, String targetBaseKey, List<String> paths, Consumer<Throwable> errorHandler) Copy a list of objects from a source bucket to a target bucketConvenience handler to ignore NoSuchKeyException.static Strings3KeyFromPath(String baseKey, String path) Form a S3 key from a base key and a path
-
Field Details
-
DELIMITER
- See Also:
-
-
Constructor Details
-
AwsUtils
public AwsUtils()
-
-
Method Details
-
buildTransferManager
public static software.amazon.awssdk.transfer.s3.S3TransferManager buildTransferManager(software.amazon.awssdk.services.s3.S3AsyncClient client) Builds theS3TransferManagerusing the sharedExecutorService -
buildTransferManager
public static software.amazon.awssdk.transfer.s3.S3TransferManager buildTransferManager(software.amazon.awssdk.services.s3.S3AsyncClient client, ThreadPoolExecutor threadPoolExecutor) Builds theS3TransferManagerusing the providedThreadPoolExecutor- Parameters:
client- theS3AsyncClientclientthreadPoolExecutor- the thread pool executor
-
copyObjects
public static void copyObjects(software.amazon.awssdk.services.s3.S3AsyncClient client, ThreadPoolExecutor threadPoolExecutor, String sourceBucket, String sourceBaseKey, String targetBucket, String targetBaseKey, List<String> paths, Consumer<Throwable> errorHandler) Copy a list of objects from a source bucket to a target bucket- Parameters:
client- TheS3AsyncClientclientthreadPoolExecutor- The thread pool executorsourceBucket- The source bucketsourceBaseKey- The base key in the source bucket (i.e. prefix for all paths)targetBucket- The target buckettargetBaseKey- The base key in the target bucket (i.e. prefix for all paths)paths- The list of paths to copyerrorHandler- The error handler to be called on copy errors. This handler will receive the cause exception and can return a CompletionException to propagate the error or handle it in any other way
-
ignoreMissingObject
Convenience handler to ignore NoSuchKeyException. It will throw a CompletionException for any other exception type- Returns:
- handler that ignores NoSuchKeyException
-
s3KeyFromPath
Form a S3 key from a base key and a path- Parameters:
baseKey- the base keypath- the path- Returns:
- s3 key format
-