Class ObjectUtils

java.lang.Object
org.jets3t.service.utils.ObjectUtils

public class ObjectUtils extends Object
Utility class for preparing files for upload into S3, or for download from S3. The methods in this class build the appropriate objects to wrap uploaded files or objects in S3 that will be downloaded to a local file.
Author:
James Murty
  • Constructor Details

    • ObjectUtils

      public ObjectUtils()
  • Method Details

    • createObjectForUpload

      public static S3Object createObjectForUpload(String objectKey, File dataFile, EncryptionUtil encryptionUtil, boolean gzipFile, BytesProgressWatcher progressWatcher) throws Exception
      Prepares a file for upload to a named object in S3, potentially transforming it if zipping or encryption is requested.

      The file will have the following metadata items added:

      Parameters:
      objectKey - the object key name to use in S3
      dataFile - the file to prepare for upload.
      encryptionUtil - if this variable is null no encryption will be applied, otherwise the provided encryption utility object will be used to encrypt the file's data.
      gzipFile - if true the file will be Gzipped.
      progressWatcher - watcher to monitor progress of file transformation and hash generation.
      Returns:
      an S3Object representing the file, or a transformed copy of the file, complete with all JetS3t-specific metadata items set and ready for upload to S3.
      Throws:
      Exception - exceptions could include IO failures, gzipping and encryption failures.
    • createObjectForUpload

      public static S3Object createObjectForUpload(String objectKey, File dataFile, EncryptionUtil encryptionUtil, boolean gzipFile) throws Exception
      Prepares a file for upload to a named object in S3, potentially transforming it if zipping or encryption is requested.

      The file will have the following metadata items added:

      Parameters:
      objectKey - the object key name to use in S3
      dataFile - the file to prepare for upload.
      encryptionUtil - if this variable is null no encryption will be applied, otherwise the provided encryption utility object will be used to encrypt the file's data.
      gzipFile - if true the file will be Gzipped.
      Returns:
      an S3Object representing the file, or a transformed copy of the file, complete with all JetS3t-specific metadata items set and ready for upload to S3.
      Throws:
      Exception - exceptions could include IO failures, gzipping and encryption failures.
    • createPackageForDownload

      public static DownloadPackage createPackageForDownload(StorageObject object, File fileTarget, boolean automaticUnzip, boolean automaticDecrypt, String encryptionPassword) throws Exception
      Creates a download package representing an S3Object that will be downloaded, and the target file the downloaded data will be written to.

      Downloaded data may be transformed if the S3Object is encrypted or gzipped and the appropriate options are set.

      Parameters:
      object - the object
      fileTarget - the file to which downloaded (and possibly transformed) data will be written.
      automaticUnzip - if true, gzipped objects will be decrypted on-the-fly as they are downloaded.
      automaticDecrypt - if true, encrypted files will be decrypted on-the-fly as they are downloaded (in which case the encryptionPassword must be correct)
      encryptionPassword - the password required to decrypt encrypted objects.
      Returns:
      a download package representing an S3Object and a taret file for the object's data.
      Throws:
      Exception
    • createPackageForDownload

      @Deprecated public static DownloadPackage createPackageForDownload(S3Object object, File fileTarget, boolean automaticUnzip, boolean automaticDecrypt, String encryptionPassword) throws Exception
      Creates a download package representing an S3Object that will be downloaded, and the target file the downloaded data will be written to.

      Downloaded data may be transformed if the S3Object is encrypted or gzipped and the appropriate options are set.

      Parameters:
      object - the object
      fileTarget - the file to which downloaded (and possibly transformed) data will be written.
      automaticUnzip - if true, gzipped objects will be decrypted on-the-fly as they are downloaded.
      automaticDecrypt - if true, encrypted files will be decrypted on-the-fly as they are downloaded (in which case the encryptionPassword must be correct)
      encryptionPassword - the password required to decrypt encrypted objects.
      Returns:
      a download package representing an S3Object and a taret file for the object's data.
      Throws:
      Exception
    • convertDirPlaceholderKeyNameToDirName

      public static String convertDirPlaceholderKeyNameToDirName(String objectKey)