Class S3Utils
java.lang.Object
com.kingsrook.qqq.backend.module.filesystem.s3.utils.S3Utils
Utility methods for working with AWS S3 (or any S3-compatible store), on an
AWS SDK v2 S3Client. Actions set the client built by S3ClientFactory from
their backend's meta data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteObject(String bucketName, String key) Delete an object (file) from a bucketgetObjectAsInputStream(S3ObjectSummary s3ObjectSummary) Get the contents (as an InputStream) for an object in s3software.amazon.awssdk.services.s3.S3ClientGetter for the S3 client.listObjectsInBucketMatchingGlob(String bucketName, String path, String glob) List the objects in an S3 bucket matching a glob, per: https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String)listObjectsInBucketMatchingGlob(String bucketName, String path, String glob, String requestedPath, AbstractFilesystemTableBackendDetails tableDetails) List the objects in an S3 bucket matching a glob, per: https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String) and also - (possibly) apply a file-name filter (based on the table's details).listObjectsInBucketMatchingGlob(String bucketName, String path, String glob, String requestedPath, AbstractFilesystemTableBackendDetails tableDetails, Integer maxListedObjects) List the objects in an S3 bucket matching a glob, as above, failing with a FilesystemException (instead of exhausting memory) if more than maxListedObjects objects match.voidmoveObject(String bucketName, String source, String destination) Move an object (file) within a bucketvoidsetS3Client(software.amazon.awssdk.services.s3.S3Client s3Client) Setter for the S3 client.voidWrite a file
-
Constructor Details
-
S3Utils
public S3Utils()
-
-
Method Details
-
listObjectsInBucketMatchingGlob
public List<S3ObjectSummary> listObjectsInBucketMatchingGlob(String bucketName, String path, String glob) throws QException List the objects in an S3 bucket matching a glob, per: https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String)- Throws:
QException
-
listObjectsInBucketMatchingGlob
public List<S3ObjectSummary> listObjectsInBucketMatchingGlob(String bucketName, String path, String glob, String requestedPath, AbstractFilesystemTableBackendDetails tableDetails) throws QException List the objects in an S3 bucket matching a glob, per: https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String) and also - (possibly) apply a file-name filter (based on the table's details).- Throws:
QException
-
listObjectsInBucketMatchingGlob
public List<S3ObjectSummary> listObjectsInBucketMatchingGlob(String bucketName, String path, String glob, String requestedPath, AbstractFilesystemTableBackendDetails tableDetails, Integer maxListedObjects) throws QException List the objects in an S3 bucket matching a glob, as above, failing with a FilesystemException (instead of exhausting memory) if more than maxListedObjects objects match. A null maxListedObjects means no cap.- Throws:
QException
-
getObjectAsInputStream
Get the contents (as an InputStream) for an object in s3 -
writeFile
-
deleteObject
Delete an object (file) from a bucket- Throws:
FilesystemException
-
moveObject
public void moveObject(String bucketName, String source, String destination) throws FilesystemException Move an object (file) within a bucket- Throws:
FilesystemException
-
setS3Client
public void setS3Client(software.amazon.awssdk.services.s3.S3Client s3Client) Setter for the S3 client. -
getS3Client
public software.amazon.awssdk.services.s3.S3Client getS3Client()Getter for the S3 client. If none was set, uses the shared client for a default (us-east-1, default credential chain) AWS connection.
-