|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jets3t.service.model.BaseS3Object
org.jets3t.service.model.S3Object
public class S3Object
An S3 object.
Field Summary | |
---|---|
static String |
METADATA_HEADER_CONTENT_DISPOSITION
|
static String |
METADATA_HEADER_CONTENT_ENCODING
|
static String |
METADATA_HEADER_CONTENT_LANGUAGE
|
static String |
METADATA_HEADER_CONTENT_LENGTH
|
static String |
METADATA_HEADER_CONTENT_MD5
|
static String |
METADATA_HEADER_CONTENT_TYPE
|
static String |
METADATA_HEADER_DATE
|
static String |
METADATA_HEADER_ETAG
|
static String |
METADATA_HEADER_HASH_MD5
|
static String |
METADATA_HEADER_LAST_MODIFIED_DATE
|
static String |
METADATA_HEADER_ORIGINAL_HASH_MD5
|
static String |
METADATA_HEADER_OWNER
|
static String |
STORAGE_CLASS_REDUCED_REDUNDANCY
|
static String |
STORAGE_CLASS_STANDARD
|
Constructor Summary | |
---|---|
S3Object()
Create an object without any associated information whatsoever. |
|
S3Object(File file)
Create an object representing a file. |
|
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. |
|
S3Object(String key)
Create an object without any associated data, and no associated bucket. |
|
S3Object(String key,
String dataString)
Create an object representing text data. |
Method Summary | |
---|---|
void |
addAllMetadata(Map metadata)
Add all the metadata information to the object from the provided map. |
void |
addMetadata(String name,
String value)
Add metadata information to the object. |
Object |
clone()
|
void |
closeDataInputStream()
Closes the object's data input stream if it exists. |
AccessControlList |
getAcl()
|
String |
getBucketName()
|
String |
getContentDisposition()
|
String |
getContentEncoding()
|
String |
getContentLanguage()
|
long |
getContentLength()
|
String |
getContentType()
|
File |
getDataInputFile()
|
InputStream |
getDataInputStream()
Returns an input stream containing this object's data, or null if there is no data associated with the object. |
String |
getETag()
|
String |
getKey()
|
Date |
getLastModifiedDate()
|
String |
getMd5HashAsBase64()
|
String |
getMd5HashAsHex()
|
Map |
getModifiableMetadata()
Returns only those object metadata items that can be modified in S3. |
S3Owner |
getOwner()
|
String |
getStorageClass()
|
String |
getVersionId()
|
boolean |
isMetadataComplete()
|
void |
setAcl(AccessControlList acl)
Set the object's ACL. |
void |
setBucketName(String bucketName)
Set the name of the bucket this object belongs to or will be placed into. |
void |
setContentDisposition(String contentDisposition)
Set the content disposition of the object. |
void |
setContentEncoding(String contentEncoding)
Set the content encoding of this object. |
void |
setContentLanguage(String contentLanguage)
Set the content language of the object. |
void |
setContentLength(long size)
Set this object's content length. |
void |
setContentType(String contentType)
Set the content type of the object. |
void |
setDataInputFile(File dataInputFile)
Sets the file containing the data content to associate with this object. |
void |
setDataInputStream(InputStream dataInputStream)
Sets an input stream containing the data content to associate with this object. |
void |
setETag(String etag)
Set the ETag value of the object based on information returned from S3. |
void |
setKey(String key)
Set the key of this object. |
void |
setLastModifiedDate(Date lastModifiedDate)
Set this object's last modified date based on information returned from S3. |
void |
setMd5Hash(byte[] md5Hash)
Set the MD5 hash value of this object's data. |
void |
setMetadataComplete(boolean isMetadataComplete)
S3 Object metadata are only complete when it is populated with all values following a HEAD or GET request. |
void |
setOwner(S3Owner owner)
Set this object's owner object based on information returned from S3. |
void |
setStorageClass(String storageClass)
Set the storage class for this object. |
String |
toString()
|
boolean |
verifyData(byte[] downloadedData)
Calculates the MD5 hash value of the given data object, and compares it against this object's hash (as stored in the Content-MD5 header for uploads, or the ETag header for downloads). |
boolean |
verifyData(File downloadedFile)
Calculates the MD5 hash value of the given data object, and compares it against this object's hash (as stored in the Content-MD5 header for uploads, or the ETag header for downloads). |
boolean |
verifyData(InputStream downloadedDataStream)
Calculates the MD5 hash value of the given data object, and compares it against this object's hash (as stored in the Content-MD5 header for uploads, or the ETag header for downloads). |
Methods inherited from class org.jets3t.service.model.BaseS3Object |
---|
addMetadata, addMetadata, containsMetadata, getMetadata, getMetadataMap, removeMetadata, replaceAllMetadata |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String METADATA_HEADER_LAST_MODIFIED_DATE
public static final String METADATA_HEADER_DATE
public static final String METADATA_HEADER_OWNER
public static final String METADATA_HEADER_ETAG
public static final String METADATA_HEADER_HASH_MD5
public static final String METADATA_HEADER_ORIGINAL_HASH_MD5
public static final String METADATA_HEADER_CONTENT_MD5
public static final String METADATA_HEADER_CONTENT_LENGTH
public static final String METADATA_HEADER_CONTENT_TYPE
public static final String METADATA_HEADER_CONTENT_ENCODING
public static final String METADATA_HEADER_CONTENT_DISPOSITION
public static final String METADATA_HEADER_CONTENT_LANGUAGE
public static final String STORAGE_CLASS_STANDARD
public static final String STORAGE_CLASS_REDUCED_REDUNDANCY
Constructor Detail |
---|
public S3Object(S3Bucket bucket, File file) throws NoSuchAlgorithmException, IOException
Mimetypes
), 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.
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.
IOException
- when an i/o error occurred reading the file
NoSuchAlgorithmException
- when this JRE doesn't support the MD5 hash algorithmpublic S3Object(File file) throws NoSuchAlgorithmException, IOException
Mimetypes
), 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.
file
- the file the object will represent. This file must exist and be readable.
IOException
- when an i/o error occurred reading the file
NoSuchAlgorithmException
- when this JRE doesn't support the MD5 hash algorithmpublic S3Object(S3Bucket bucket, String key, String dataString) throws NoSuchAlgorithmException, IOException
text/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.
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.
IOException
NoSuchAlgorithmException
- when this JRE doesn't support the MD5 hash algorithmpublic S3Object(String key, String dataString) throws NoSuchAlgorithmException, IOException
text/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.
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.
IOException
NoSuchAlgorithmException
- when this JRE doesn't support the MD5 hash algorithmpublic S3Object(String key)
key
- the key name for the object.public S3Object(S3Bucket bucket, String key)
bucket
- the bucket the object belongs to, or will be placed in.key
- the key name for the object.public S3Object()
Method Detail |
---|
public String toString()
toString
in class Object
public InputStream getDataInputStream() throws S3ServiceException
If you are downloading data from S3, you should consider verifying the
integrity of the data you read from this stream using one of the
verifyData(InputStream)
methods.
S3ServiceException
public void setDataInputStream(InputStream dataInputStream)
Note: If the data content comes from a file, use the alternate method
setDataInputFile(File)
which allows objects to lazily open files and avoid any
Operating System limits on the number of files that may be opened simultaneously.
Note 2: This method does not calculate an MD5 hash of the input data,
which means S3 will not be able to recognize if data are corrupted in transit.
To allow S3 to verify data you upload, you should set the MD5 hash value of
your data using setMd5Hash(byte[])
.
This method will set the object's file data reference to null.
dataInputStream
- an input stream containing the object's data.public void setDataInputFile(File dataInputFile)
getDataInputStream()
is called.
Note 2: This method does not calculate an MD5 hash of the input data,
which means S3 will not be able to recognize if data are corrupted in transit.
To allow S3 to verify data you upload, you should set the MD5 hash value of
your data using setMd5Hash(byte[])
.
This method will set the object's input stream data reference to null.
dataInputFile
- a file containing the object's data.public File getDataInputFile()
public void closeDataInputStream() throws IOException
IOException
public String getETag()
public void setETag(String etag)
etag
- the ETag value as provided by S3.public String getMd5HashAsHex()
md5-hash
, or null if the hash value is not available.public String getMd5HashAsBase64()
Content-MD5
, or as derived from an ETag
or
md5-hash
hex-encoded version of the hash. Returns null if the hash value is not
available.public void setMd5Hash(byte[] md5Hash)
Content-MD5
(Base64-encoded)
and the jets3t-specific md5-hash
(Hex-encoded).
md5Hash
- the MD5 hash value of the object's data.public Date getLastModifiedDate()
public void setLastModifiedDate(Date lastModifiedDate)
lastModifiedDate
- public S3Owner getOwner()
public void setOwner(S3Owner owner)
owner
- public long getContentLength()
public void setContentLength(long size)
setDataInputStream(InputStream)
or setDataInputFile(File)
methods,
you must also set the content length value.
size
- public String getStorageClass()
public void setStorageClass(String storageClass)
storageClass
- public String getContentType()
public void setContentType(String contentType)
Mimetypes
).
You should set the content type for associated String or InputStream data.
contentType
- public String getContentLanguage()
public void setContentLanguage(String contentLanguage)
contentLanguage
- public String getContentDisposition()
public void setContentDisposition(String contentDisposition)
contentDisposition
- public String getContentEncoding()
public void setContentEncoding(String contentEncoding)
contentEncoding
- public String getBucketName()
public void setBucketName(String bucketName)
bucketName
- the name for the bucket.public AccessControlList getAcl()
public void setAcl(AccessControlList acl)
x-amz-acl
.
acl
- public String getKey()
public void setKey(String key)
key
- the key for this object.public boolean isMetadataComplete()
public void setMetadataComplete(boolean isMetadataComplete)
isMetadataComplete
- public void addMetadata(String name, String value)
addMetadata
in class BaseS3Object
name
- value
- public void addAllMetadata(Map metadata)
addAllMetadata
in class BaseS3Object
metadata
- public Map getModifiableMetadata()
public String getVersionId()
public Object clone()
clone
in class Object
public boolean verifyData(File downloadedFile) throws NoSuchAlgorithmException, FileNotFoundException, IOException
downloadedFile
-
NoSuchAlgorithmException
FileNotFoundException
IOException
public boolean verifyData(byte[] downloadedData) throws NoSuchAlgorithmException, FileNotFoundException, IOException
downloadedData
-
NoSuchAlgorithmException
FileNotFoundException
IOException
public boolean verifyData(InputStream downloadedDataStream) throws NoSuchAlgorithmException, FileNotFoundException, IOException
downloadedDataStream
- the input stream of a downloaded S3Object.
NoSuchAlgorithmException
FileNotFoundException
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |