Class S3Utils

java.lang.Object
com.kingsrook.qqq.backend.module.filesystem.s3.utils.S3Utils

public class S3Utils extends Object
Utility methods for working with AWS S3. Note: May need a constructor (or similar) in the future that takes the S3BackendMetaData - e.g., if we need some metaData to construct the AmazonS3 (api client) object, such as region, or authentication.
  • Constructor Details

    • S3Utils

      public S3Utils()
  • Method Details

    • listObjectsInBucketMatchingGlob

      public List<com.amazonaws.services.s3.model.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<com.amazonaws.services.s3.model.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
    • getObjectAsInputStream

      public InputStream getObjectAsInputStream(com.amazonaws.services.s3.model.S3ObjectSummary s3ObjectSummary)
      Get the contents (as an InputStream) for an object in s3
    • writeFile

      public void writeFile(String bucket, String key, byte[] contents, String contentType)
      Write a file
    • deleteObject

      public void deleteObject(String bucketName, String key) throws FilesystemException
      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
    • setAmazonS3

      public void setAmazonS3(com.amazonaws.services.s3.AmazonS3 amazonS3)
      Setter for AmazonS3 client object.
    • getAmazonS3

      public com.amazonaws.services.s3.AmazonS3 getAmazonS3()
      Getter for AmazonS3 client object.