com.amazonaws.services.s3.model
Class ObjectMetadata

java.lang.Object
  extended by com.amazonaws.services.s3.model.ObjectMetadata
All Implemented Interfaces:
com.amazonaws.services.s3.internal.ObjectExpirationResult, com.amazonaws.services.s3.internal.ServerSideEncryptionResult

public class ObjectMetadata
extends Object
implements com.amazonaws.services.s3.internal.ServerSideEncryptionResult, com.amazonaws.services.s3.internal.ObjectExpirationResult

Represents the object metadata that is stored with Amazon S3. This includes custom user-supplied metadata, as well as the standard HTTP headers that Amazon S3 sends and receives (Content-Length, ETag, Content-MD5, etc.).


Field Summary
static String AES_256_SERVER_SIDE_ENCRYPTION
           
 
Constructor Summary
ObjectMetadata()
           
 
Method Summary
 void addUserMetadata(String key, String value)
           Adds the key value pair of custom user-metadata for the associated object.
 String getCacheControl()
           Gets the optional Cache-Control HTTP header which allows the user to specify caching behavior along the HTTP request/reply chain.
 String getContentDisposition()
           Gets the optional Content-Disposition HTTP header, which specifies presentation information for the object such as the recommended filename for the object to be saved as.
 String getContentEncoding()
           Gets the optional Content-Encoding HTTP header specifying what content encodings have been applied to the object and what decoding mechanisms must be applied in order to obtain the media-type referenced by the Content-Type field.
 long getContentLength()
           Gets the Content-Length HTTP header indicating the size of the associated object in bytes.
 String getContentMD5()
           Gets the base64 encoded 128-bit MD5 digest of the associated object (content - not including headers) according to RFC 1864.
 String getContentType()
           Gets the Content-Type HTTP header, which indicates the type of content stored in the associated object.
 String getETag()
          Gets the hex encoded 128-bit MD5 digest of the associated object according to RFC 1864.
 Date getExpirationTime()
          Returns the expiration time for this object, or null if it doesn't expire.
 String getExpirationTimeRuleId()
          Returns the BucketLifecycleConfiguration rule ID for this object's expiration, or null if it doesn't expire.
 Date getLastModified()
          Gets the value of the Last-Modified header, indicating the date and time at which Amazon S3 last recorded a modification to the associated object.
 Map<String,Object> getRawMetadata()
          For internal use only.
 String getServerSideEncryption()
          Returns the server-side encryption algorithm for the object, or null if none was used.
 Map<String,String> getUserMetadata()
           Gets the custom user-metadata for the associated object.
 String getVersionId()
          Gets the version ID of the associated Amazon S3 object if available.
 void setCacheControl(String cacheControl)
           Sets the optional Cache-Control HTTP header which allows the user to specify caching behavior along the HTTP request/reply chain.
 void setContentDisposition(String disposition)
           Sets the optional Content-Disposition HTTP header, which specifies presentational information such as the recommended filename for the object to be saved as.
 void setContentEncoding(String encoding)
           Sets the optional Content-Encoding HTTP header specifying what content encodings have been applied to the object and what decoding mechanisms must be applied in order to obtain the media-type referenced by the Content-Type field.
 void setContentLength(long contentLength)
           Sets the Content-Length HTTP header indicating the size of the associated object in bytes.
 void setContentMD5(String md5Base64)
           Sets the base64 encoded 128-bit MD5 digest of the associated object (content - not including headers) according to RFC 1864.
 void setContentType(String contentType)
           Sets the Content-Type HTTP header indicating the type of content stored in the associated object.
 void setExpirationTime(Date expirationTime)
          Sets the expiration time for the object.
 void setExpirationTimeRuleId(String expirationTimeRuleId)
          Sets the BucketLifecycleConfiguration rule ID for this object's expiration
 void setHeader(String key, Object value)
          For internal use only.
 void setLastModified(Date lastModified)
          For internal use only.
 void setServerSideEncryption(String serverSideEncryption)
          Sets the server-side encryption algorithm for the object.
 void setUserMetadata(Map<String,String> userMetadata)
           Sets the custom user-metadata for the associated object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AES_256_SERVER_SIDE_ENCRYPTION

public static final String AES_256_SERVER_SIDE_ENCRYPTION
See Also:
Constant Field Values
Constructor Detail

ObjectMetadata

public ObjectMetadata()
Method Detail

getUserMetadata

public Map<String,String> getUserMetadata()

Gets the custom user-metadata for the associated object.

Amazon S3 can store additional metadata on objects by internally representing it as HTTP headers prefixed with "x-amz-meta-". Use user-metadata to store arbitrary metadata alongside their data in Amazon S3. When setting user metadata, callers should not include the internal "x-amz-meta-" prefix; this library will handle that for them. Likewise, when callers retrieve custom user-metadata, they will not see the "x-amz-meta-" header prefix.

User-metadata keys are case insensitive and will be returned as lowercase strings, even if they were originally specified with uppercase strings.

Note that user-metadata for an object is limited by the HTTP request header limit. All HTTP headers included in a request (including user metadata headers and other standard HTTP headers) must be less than 8KB.

Returns:
The custom user metadata for the associated object.
See Also:
setUserMetadata(Map), addUserMetadata(String, String)

setUserMetadata

public void setUserMetadata(Map<String,String> userMetadata)

Sets the custom user-metadata for the associated object.

Amazon S3 can store additional metadata on objects by internally representing it as HTTP headers prefixed with "x-amz-meta-". Use user-metadata to store arbitrary metadata alongside their data in Amazon S3. When setting user metadata, callers should not include the internal "x-amz-meta-" prefix; this library will handle that for them. Likewise, when callers retrieve custom user-metadata, they will not see the "x-amz-meta-" header prefix.

User-metadata keys are case insensitive and will be returned as lowercase strings, even if they were originally specified with uppercase strings.

Note that user-metadata for an object is limited by the HTTP request header limit. All HTTP headers included in a request (including user metadata headers and other standard HTTP headers) must be less than 8KB.

Parameters:
userMetadata - The custom user-metadata for the associated object. Note that the key should not include the internal S3 HTTP header prefix.
See Also:
getUserMetadata(), addUserMetadata(String, String)

setHeader

public void setHeader(String key,
                      Object value)
For internal use only. Sets a specific metadata header value. Not intended to be called by external code.

Parameters:
key - The name of the header being set.
value - The value for the header.

addUserMetadata

public void addUserMetadata(String key,
                            String value)

Adds the key value pair of custom user-metadata for the associated object. If the entry in the custom user-metadata map already contains the specified key, it will be replaced with these new contents.

Amazon S3 can store additional metadata on objects by internally representing it as HTTP headers prefixed with "x-amz-meta-". Use user-metadata to store arbitrary metadata alongside their data in Amazon S3. When setting user metadata, callers should not include the internal "x-amz-meta-" prefix; this library will handle that for them. Likewise, when callers retrieve custom user-metadata, they will not see the "x-amz-meta-" header prefix.

Note that user-metadata for an object is limited by the HTTP request header limit. All HTTP headers included in a request (including user metadata headers and other standard HTTP headers) must be less than 8KB.

Parameters:
key - The key for the custom user metadata entry. Note that the key should not include the internal S3 HTTP header prefix.
value - The value for the custom user-metadata entry.
See Also:
setUserMetadata(Map), getUserMetadata()

getRawMetadata

public Map<String,Object> getRawMetadata()
For internal use only. Gets a map of the raw metadata/headers for the associated object.

Returns:
A map of the raw metadata/headers for the associated object.

getLastModified

public Date getLastModified()
Gets the value of the Last-Modified header, indicating the date and time at which Amazon S3 last recorded a modification to the associated object.

Returns:
The date and time at which Amazon S3 last recorded a modification to the associated object. Returns null if the Last-Modified header hasn't been set.

setLastModified

public void setLastModified(Date lastModified)
For internal use only. Sets the Last-Modified header value indicating the date and time at which Amazon S3 last recorded a modification to the associated object.

Parameters:
lastModified - The date and time at which Amazon S3 last recorded a modification to the associated object.

getContentLength

public long getContentLength()

Gets the Content-Length HTTP header indicating the size of the associated object in bytes.

This field is required when uploading objects to S3, but the AWS S3 Java client will automatically set it when working directly with files. When uploading directly from a stream, set this field if possible. Otherwise the client must buffer the entire stream in order to calculate the content length before sending the data to Amazon S3.

For more information on the Content-Length HTTP header, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13

Returns:
The Content-Length HTTP header indicating the size of the associated object in bytes. Returns null if it hasn't been set yet.
See Also:
setContentLength(long)

setContentLength

public void setContentLength(long contentLength)

Sets the Content-Length HTTP header indicating the size of the associated object in bytes.

This field is required when uploading objects to S3, but the AWS S3 Java client will automatically set it when working directly with files. When uploading directly from a stream, set this field if possible. Otherwise the client must buffer the entire stream in order to calculate the content length before sending the data to Amazon S3.

For more information on the Content-Length HTTP header, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13

Parameters:
contentLength - The Content-Length HTTP header indicating the size of the associated object in bytes.
See Also:
getContentLength()

getContentType

public String getContentType()

Gets the Content-Type HTTP header, which indicates the type of content stored in the associated object. The value of this header is a standard MIME type.

When uploading files, the AWS S3 Java client will attempt to determine the correct content type if one hasn't been set yet. Users are responsible for ensuring a suitable content type is set when uploading streams. If no content type is provided and cannot be determined by the filename, the default content type, "application/octet-stream", will be used.

For more information on the Content-Type header, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17

Returns:
The HTTP Content-Type header, indicating the type of content stored in the associated S3 object. Returns null if it hasn't been set.
See Also:
setContentType(String)

setContentType

public void setContentType(String contentType)

Sets the Content-Type HTTP header indicating the type of content stored in the associated object. The value of this header is a standard MIME type.

When uploading files, the AWS S3 Java client will attempt to determine the correct content type if one hasn't been set yet. Users are responsible for ensuring a suitable content type is set when uploading streams. If no content type is provided and cannot be determined by the filename, the default content type "application/octet-stream" will be used.

For more information on the Content-Type header, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17

Parameters:
contentType - The HTTP Content-Type header indicating the type of content stored in the associated S3 object.
See Also:
getContentType()

getContentEncoding

public String getContentEncoding()

Gets the optional Content-Encoding HTTP header specifying what content encodings have been applied to the object and what decoding mechanisms must be applied in order to obtain the media-type referenced by the Content-Type field.

For more information on how the Content-Encoding HTTP header works, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11

Returns:
The HTTP Content-Encoding header. Returns null if it hasn't been set.
See Also:
setContentType(String)

setContentEncoding

public void setContentEncoding(String encoding)

Sets the optional Content-Encoding HTTP header specifying what content encodings have been applied to the object and what decoding mechanisms must be applied in order to obtain the media-type referenced by the Content-Type field.

For more information on how the Content-Encoding HTTP header works, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11

Parameters:
encoding - The HTTP Content-Encoding header, as defined in RFC 2616.
See Also:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11, getContentType()

getCacheControl

public String getCacheControl()

Gets the optional Cache-Control HTTP header which allows the user to specify caching behavior along the HTTP request/reply chain.

For more information on how the Cache-Control HTTP header affects HTTP requests and responses, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9

Returns:
The HTTP Cache-Control header as defined in RFC 2616. Returns null if it hasn't been set.
See Also:
setCacheControl(String)

setCacheControl

public void setCacheControl(String cacheControl)

Sets the optional Cache-Control HTTP header which allows the user to specify caching behavior along the HTTP request/reply chain.

For more information on how the Cache-Control HTTP header affects HTTP requests and responses see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9

Parameters:
cacheControl - The HTTP Cache-Control header as defined in RFC 2616.
See Also:
getCacheControl()

setContentMD5

public void setContentMD5(String md5Base64)

Sets the base64 encoded 128-bit MD5 digest of the associated object (content - not including headers) according to RFC 1864. This data is used as a message integrity check to verify that the data received by Amazon S3 is the same data that the caller sent.

This field represents the base64 encoded 128-bit MD5 digest digest of an object's content as calculated on the caller's side. The ETag metadata field represents the hex encoded 128-bit MD5 digest as computed by Amazon S3.

The AWS S3 Java client will attempt to calculate this field automatically when uploading files to Amazon S3.

Parameters:
md5Base64 - The base64 encoded MD5 hash of the content for the object associated with this metadata.
See Also:
getContentMD5()

getContentMD5

public String getContentMD5()

Gets the base64 encoded 128-bit MD5 digest of the associated object (content - not including headers) according to RFC 1864. This data is used as a message integrity check to verify that the data received by Amazon S3 is the same data that the caller sent.

This field represents the base64 encoded 128-bit MD5 digest digest of an object's content as calculated on the caller's side. The ETag metadata field represents the hex encoded 128-bit MD5 digest as computed by Amazon S3.

The AWS S3 Java client will attempt to calculate this field automatically when uploading files to Amazon S3.

Returns:
The base64 encoded MD5 hash of the content for the associated object. Returns null if the MD5 hash of the content hasn't been set.
See Also:
setContentMD5(String)

setContentDisposition

public void setContentDisposition(String disposition)

Sets the optional Content-Disposition HTTP header, which specifies presentational information such as the recommended filename for the object to be saved as.

For more information on how the Content-Disposition header affects HTTP client behavior, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1

Parameters:
disposition - The value for the Content-Disposition header.
See Also:
getContentDisposition()

getContentDisposition

public String getContentDisposition()

Gets the optional Content-Disposition HTTP header, which specifies presentation information for the object such as the recommended filename for the object to be saved as.

For more information on how the Content-Disposition header affects HTTP client behavior, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1

Returns:
The value of the Content-Disposition header. Returns null if the Content-Disposition header hasn't been set.
See Also:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1, setCacheControl(String)

getETag

public String getETag()
Gets the hex encoded 128-bit MD5 digest of the associated object according to RFC 1864. This data is used as an integrity check to verify that the data received by the caller is the same data that was sent by Amazon S3.

This field represents the hex encoded 128-bit MD5 digest of an object's content as calculated by Amazon S3. The ContentMD5 field represents the base64 encoded 128-bit MD5 digest as calculated on the caller's side.

Returns:
The hex encoded MD5 hash of the content for the associated object as calculated by Amazon S3. Returns null if it hasn't been set yet.

getVersionId

public String getVersionId()
Gets the version ID of the associated Amazon S3 object if available. Version IDs are only assigned to objects when an object is uploaded to an Amazon S3 bucket that has object versioning enabled.

Returns:
The version ID of the associated Amazon S3 object if available.

getServerSideEncryption

public String getServerSideEncryption()
Returns the server-side encryption algorithm for the object, or null if none was used.

Specified by:
getServerSideEncryption in interface com.amazonaws.services.s3.internal.ServerSideEncryptionResult

setServerSideEncryption

public void setServerSideEncryption(String serverSideEncryption)
Sets the server-side encryption algorithm for the object.

Specified by:
setServerSideEncryption in interface com.amazonaws.services.s3.internal.ServerSideEncryptionResult
Parameters:
serverSideEncryption - The server-side encryption algorithm for the object.

getExpirationTime

public Date getExpirationTime()
Returns the expiration time for this object, or null if it doesn't expire.

Specified by:
getExpirationTime in interface com.amazonaws.services.s3.internal.ObjectExpirationResult

setExpirationTime

public void setExpirationTime(Date expirationTime)
Sets the expiration time for the object.

Specified by:
setExpirationTime in interface com.amazonaws.services.s3.internal.ObjectExpirationResult
Parameters:
expirationTime - The expiration time for the object.

getExpirationTimeRuleId

public String getExpirationTimeRuleId()
Returns the BucketLifecycleConfiguration rule ID for this object's expiration, or null if it doesn't expire.

Specified by:
getExpirationTimeRuleId in interface com.amazonaws.services.s3.internal.ObjectExpirationResult
See Also:
BucketLifecycleConfiguration.Rule.getId()

setExpirationTimeRuleId

public void setExpirationTimeRuleId(String expirationTimeRuleId)
Sets the BucketLifecycleConfiguration rule ID for this object's expiration

Specified by:
setExpirationTimeRuleId in interface com.amazonaws.services.s3.internal.ObjectExpirationResult
Parameters:
expirationTimeRuleId - The rule ID for this object's expiration


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.