org.jets3t.service.utils
Class ObjectUtils

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

public class ObjectUtils
extends java.lang.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.


Constructor Summary
ObjectUtils()
           
 
Method Summary
static java.lang.String convertDirPlaceholderKeyNameToDirName(java.lang.String objectKey)
           
static S3Object createObjectForUpload(java.lang.String objectKey, java.io.File dataFile, EncryptionUtil encryptionUtil, boolean gzipFile)
          Prepares a file for upload to a named object in S3, potentially transforming it if zipping or encryption is requested.
static S3Object createObjectForUpload(java.lang.String objectKey, java.io.File dataFile, EncryptionUtil encryptionUtil, boolean gzipFile, BytesProgressWatcher progressWatcher)
          Prepares a file for upload to a named object in S3, potentially transforming it if zipping or encryption is requested.
static DownloadPackage createPackageForDownload(S3Object object, java.io.File fileTarget, boolean automaticUnzip, boolean automaticDecrypt, java.lang.String encryptionPassword)
          Deprecated. 0.8.0 use createPackageForDownload(StorageObject, File, boolean, boolean, String) instead.
static DownloadPackage createPackageForDownload(StorageObject object, java.io.File fileTarget, boolean automaticUnzip, boolean automaticDecrypt, java.lang.String encryptionPassword)
          Creates a download package representing an S3Object that will be downloaded, and the target file the downloaded data will be written to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectUtils

public ObjectUtils()
Method Detail

createObjectForUpload

public static S3Object createObjectForUpload(java.lang.String objectKey,
                                             java.io.File dataFile,
                                             EncryptionUtil encryptionUtil,
                                             boolean gzipFile,
                                             BytesProgressWatcher progressWatcher)
                                      throws java.lang.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:
java.lang.Exception - exceptions could include IO failures, gzipping and encryption failures.

createObjectForUpload

public static S3Object createObjectForUpload(java.lang.String objectKey,
                                             java.io.File dataFile,
                                             EncryptionUtil encryptionUtil,
                                             boolean gzipFile)
                                      throws java.lang.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:
java.lang.Exception - exceptions could include IO failures, gzipping and encryption failures.

createPackageForDownload

public static DownloadPackage createPackageForDownload(StorageObject object,
                                                       java.io.File fileTarget,
                                                       boolean automaticUnzip,
                                                       boolean automaticDecrypt,
                                                       java.lang.String encryptionPassword)
                                                throws java.lang.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:
java.lang.Exception

createPackageForDownload

@Deprecated
public static DownloadPackage createPackageForDownload(S3Object object,
                                                                  java.io.File fileTarget,
                                                                  boolean automaticUnzip,
                                                                  boolean automaticDecrypt,
                                                                  java.lang.String encryptionPassword)
                                                throws java.lang.Exception
Deprecated. 0.8.0 use createPackageForDownload(StorageObject, File, boolean, boolean, String) instead.

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:
java.lang.Exception

convertDirPlaceholderKeyNameToDirName

public static java.lang.String convertDirPlaceholderKeyNameToDirName(java.lang.String objectKey)