Class Utils


  • public final class Utils
    extends Object
    Amazon S3 utilities.
    • Method Detail

      • openService

        public static software.amazon.awssdk.services.s3.S3Client openService​(Properties prop,
                                                                              boolean accReq)
        Create S3Client from properties.
        Parameters:
        prop - properties to configure @link S3Client
        accReq - boolean indicating whether to accelerate requests
        Returns:
        S3Client
      • openAsyncService

        public static software.amazon.awssdk.services.s3.S3AsyncClient openAsyncService​(Properties prop)
        Create S3Client from properties.
        Parameters:
        prop - properties to configure @link S3Client
        Returns:
        S3Client
      • createPresigner

        public static software.amazon.awssdk.services.s3.presigner.S3Presigner createPresigner​(software.amazon.awssdk.services.s3.S3Client s3Client,
                                                                                               Properties props)
        Creates an S3Presigner instance using the provided S3Client and S3 configuration properties.

        The presigner is used to generate pre-signed URLs for S3 operations, allowing secure, time-limited access to S3 resources without exposing credentials.

        Parameters:
        s3Client - the S3Client to use for presigning requests
        props - the properties containing S3 configuration (credentials, region, etc.)
        Returns:
        a configured S3Presigner instance
      • readConfig

        public static Properties readConfig​(String fileName)
                                     throws IOException
        Read a configuration properties file. If the file name ends with ";burn", the file is deleted after reading.
        Parameters:
        fileName - the properties file name
        Returns:
        the properties
        Throws:
        IOException - if the file doesn't exist
      • getDataEncryption

        public static DataEncryption getDataEncryption​(Properties props)
        Determines the data encryption type to use for S3 operations based on the provided properties.

        If the property S3_ENCRYPTION is set, returns the corresponding DataEncryption enum value. If the property is not set or is invalid, returns DataEncryption.NONE.

        Parameters:
        props - the properties containing S3 configuration
        Returns:
        the DataEncryption type to use
      • setRemoteStorageMode

        public static void setRemoteStorageMode​(Properties properties)
        Sets the remote storage mode in the provided properties based on the S3 endpoint.

        If the endpoint contains "googleapis", the mode is set to GCP. Otherwise, it is set to S3. If the mode was previously set to S3 but the endpoint is for GCP, a warning is logged and the mode is overridden.

        Parameters:
        properties - the properties to update with the remote storage mode