Package org.jets3t.service.model
Class S3Object
- java.lang.Object
-
- org.jets3t.service.model.BaseStorageItem
-
- org.jets3t.service.model.StorageObject
-
- org.jets3t.service.model.S3Object
-
- All Implemented Interfaces:
Cloneable
public class S3Object extends StorageObject implements Cloneable
An S3 object.- Author:
- James Murty
-
-
Field Summary
Fields Modifier and Type Field Description static String
S3_VERSION_ID
static String
STORAGE_CLASS_REDUCED_REDUNDANCY
static String
STORAGE_CLASS_STANDARD
-
Fields inherited from class org.jets3t.service.model.StorageObject
METADATA_HEADER_HASH_MD5, METADATA_HEADER_ORIGINAL_HASH_MD5
-
Fields inherited from class org.jets3t.service.model.BaseStorageItem
METADATA_HEADER_CONTENT_DISPOSITION, METADATA_HEADER_CONTENT_ENCODING, METADATA_HEADER_CONTENT_LANGUAGE, METADATA_HEADER_CONTENT_LENGTH, METADATA_HEADER_CONTENT_MD5, METADATA_HEADER_CONTENT_TYPE, METADATA_HEADER_CREATION_DATE, METADATA_HEADER_DATE, METADATA_HEADER_ETAG, METADATA_HEADER_LAST_MODIFIED_DATE
-
-
Constructor Summary
Constructors Constructor Description S3Object()
Create an object without any associated information whatsoever.S3Object(File file)
Create an object representing a file.S3Object(String key)
Create an object without any associated data, and no associated bucket.S3Object(String key, byte[] data)
Create an object representing binary data.S3Object(String key, String dataString)
Create an object representing text data.S3Object(S3Bucket bucket, File file)
Create an object representing a file.S3Object(S3Bucket bucket, String key)
Create an object without any associated data.S3Object(S3Bucket bucket, String key, String dataString)
Create an object representing text data.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static S3Object[]
cast(StorageObject[] objects)
Object
clone()
String
getVersionId()
void
setAcl(AccessControlList acl)
Set the object's ACL.String
toString()
-
Methods inherited from class org.jets3t.service.model.StorageObject
addAllMetadata, addMetadata, closeDataInputStream, getAcl, getBucketName, getContentDisposition, getContentEncoding, getContentLanguage, getContentLength, getContentType, getDataInputFile, getDataInputStream, getETag, getKey, getLastModifiedDate, getMd5HashAsBase64, getMd5HashAsHex, getModifiableMetadata, getStorageClass, isDirectoryPlaceholder, isMetadataComplete, setBucketName, setContentDisposition, setContentEncoding, setContentLanguage, setContentLength, setContentType, setDataInputFile, setDataInputStream, setETag, setKey, setLastModifiedDate, setMd5Hash, setMetadataComplete, setStorageClass, verifyData, verifyData, verifyData
-
Methods inherited from class org.jets3t.service.model.BaseStorageItem
addMetadata, addMetadata, containsMetadata, getMetadata, getMetadataMap, getName, getOwner, removeMetadata, replaceAllMetadata, setName, setOwner
-
-
-
-
Field Detail
-
STORAGE_CLASS_STANDARD
public static final String STORAGE_CLASS_STANDARD
- See Also:
- Constant Field Values
-
STORAGE_CLASS_REDUCED_REDUNDANCY
public static final String STORAGE_CLASS_REDUCED_REDUNDANCY
- See Also:
- Constant Field Values
-
S3_VERSION_ID
public static final String S3_VERSION_ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
S3Object
public S3Object(S3Bucket bucket, File file) throws NoSuchAlgorithmException, IOException
Create an object representing a file. The object is initialised with the file's name as its key, the file's content as its data, a content type based on the file's extension (seeMimetypes
), and a content length matching the file's size. The file's MD5 hash value is also calculated and provided to S3, so the service can verify that no data are corrupted in transit.NOTE: The automatic calculation of a file's MD5 hash digest as performed by this constructor could take some time for large files, or for many small ones.
- Parameters:
bucket
- the bucket the object belongs to, or will be placed in.file
- the file the object will represent. This file must exist and be readable.- Throws:
IOException
- when an i/o error occurred reading the fileNoSuchAlgorithmException
- when this JRE doesn't support the MD5 hash algorithm
-
S3Object
public S3Object(File file) throws NoSuchAlgorithmException, IOException
Create an object representing a file. The object is initialised with the file's name as its key, the file's content as its data, a content type based on the file's extension (seeMimetypes
), and a content length matching the file's size. The file's MD5 hash value is also calculated and provided to S3, so the service can verify that no data are corrupted in transit.NOTE: The automatic calculation of a file's MD5 hash digest as performed by this constructor could take some time for large files, or for many small ones.
- Parameters:
file
- the file the object will represent. This file must exist and be readable.- Throws:
IOException
- when an i/o error occurred reading the fileNoSuchAlgorithmException
- when this JRE doesn't support the MD5 hash algorithm
-
S3Object
public S3Object(S3Bucket bucket, String key, String dataString) throws NoSuchAlgorithmException, IOException
Create an object representing text data. The object is initialized with the given key, the given string as its data content (encoded as UTF-8), a content type oftext/plain; charset=utf-8
, and a content length matching the string's length. The given string's MD5 hash value is also calculated and provided to S3, so the service can verify that no data are corrupted in transit.NOTE: The automatic calculation of the MD5 hash digest as performed by this constructor could take some time for large strings, or for many small ones.
- Parameters:
bucket
- the bucket the object belongs to, or will be placed in.key
- the key name for the object.dataString
- the text data the object will contain. Text data will be encoded as UTF-8. This string cannot be null.- Throws:
IOException
NoSuchAlgorithmException
- when this JRE doesn't support the MD5 hash algorithm
-
S3Object
public S3Object(String key, String dataString) throws NoSuchAlgorithmException, IOException
Create an object representing text data. The object is initialized with the given key, the given string as its data content (encoded as UTF-8), a content type oftext/plain; charset=utf-8
, and a content length matching the string's length. The given string's MD5 hash value is also calculated and provided to S3, so the service can verify that no data are corrupted in transit.NOTE: The automatic calculation of the MD5 hash digest as performed by this constructor could take some time for large strings, or for many small ones.
- Parameters:
key
- the key name for the object.dataString
- the text data the object will contain. Text data will be encoded as UTF-8. This string cannot be null.- Throws:
IOException
NoSuchAlgorithmException
- when this JRE doesn't support the MD5 hash algorithm
-
S3Object
public S3Object(String key, byte[] data) throws NoSuchAlgorithmException, IOException
Create an object representing binary data. The object is initialized with the given key, the bytes as its data content, a content type ofapplication/octet-stream
, and a content length matching the byte array's length. The MD5 hash value of the byte data is also calculated and provided to the target service, so the service can verify that no data are corrupted in transit.- Parameters:
key
- the key name for the object.data
- the byte data the object will contain, cannot be null.- Throws:
IOException
NoSuchAlgorithmException
- when this JRE doesn't support the MD5 hash algorithm
-
S3Object
public S3Object(String key)
Create an object without any associated data, and no associated bucket.- Parameters:
key
- the key name for the object.
-
S3Object
public S3Object(S3Bucket bucket, String key)
Create an object without any associated data.- Parameters:
bucket
- the bucket the object belongs to, or will be placed in.key
- the key name for the object.
-
S3Object
public S3Object()
Create an object without any associated information whatsoever.
-
-
Method Detail
-
toString
public String toString()
- Overrides:
toString
in classStorageObject
-
setAcl
public void setAcl(AccessControlList acl)
Set the object's ACL. If a pre-canned REST ACL is used, the plain-text representation of the canned ACL is also added as a metadata headerx-amz-acl
.- Overrides:
setAcl
in classStorageObject
- Parameters:
acl
-
-
getVersionId
public String getVersionId()
-
clone
public Object clone()
- Overrides:
clone
in classStorageObject
-
cast
public static S3Object[] cast(StorageObject[] objects)
-
-