public class S3Object extends java.lang.Object implements java.io.Closeable, java.io.Serializable, S3RequesterChargedResult
ObjectMetadata
,
Serialized FormModifier and Type | Field and Description |
---|---|
private java.lang.String |
bucketName
The name of the bucket in which this object is contained
|
private boolean |
isRequesterCharged
Indicates if the requester is charged for downloading the data from
Requester Pays Buckets.
|
private java.lang.String |
key
The key under which this object is stored
|
private ObjectMetadata |
metadata
The metadata stored by Amazon S3 for this object
|
private S3ObjectInputStream |
objectContent
The stream containing the contents of this object from S3
|
private java.lang.String |
redirectLocation
The redirect location for this object
|
private static long |
serialVersionUID |
Constructor and Description |
---|
S3Object() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Releases any underlying system resources.
|
java.lang.String |
getBucketName()
Gets the name of the bucket in which this object is contained.
|
java.lang.String |
getKey()
Gets the key under which this object is stored.
|
S3ObjectInputStream |
getObjectContent()
Gets the input stream containing the contents of this object.
|
ObjectMetadata |
getObjectMetadata()
Gets the metadata stored by Amazon S3 for this object.
|
java.lang.String |
getRedirectLocation()
Gets the redirect location for this object.
|
boolean |
isRequesterCharged()
Returns true if the user has enabled Requester Pays option when
conducting this operation from Requester Pays Bucket; else false.
|
void |
setBucketName(java.lang.String bucketName)
Sets the name of the bucket in which this object is contained.
|
void |
setKey(java.lang.String key)
Sets the key under which this object is stored.
|
void |
setObjectContent(java.io.InputStream objectContent)
Sets the input stream containing this object's contents.
|
void |
setObjectContent(S3ObjectInputStream objectContent)
Sets the input stream containing this object's contents.
|
void |
setObjectMetadata(ObjectMetadata metadata)
Sets the object metadata for this object.
|
void |
setRedirectLocation(java.lang.String redirectLocation)
Sets the redirect location for this object.
|
void |
setRequesterCharged(boolean isRequesterCharged)
Used for conducting this operation from a Requester Pays Bucket.
|
java.lang.String |
toString() |
private static final long serialVersionUID
private java.lang.String key
private java.lang.String bucketName
private ObjectMetadata metadata
private transient S3ObjectInputStream objectContent
private java.lang.String redirectLocation
private boolean isRequesterCharged
public ObjectMetadata getObjectMetadata()
ObjectMetadata
object
includes any custom user metadata supplied by the caller when the object was uploaded, as
well as HTTP metadata such as content length and content type.getObjectContent()
public void setObjectMetadata(ObjectMetadata metadata)
NOTE: This does not update the object metadata stored in Amazon
S3, but only updates this object in local memory. To update an object's
metadata in S3, use AmazonS3.copyObject(CopyObjectRequest)
to
copy the object to a new (or the same location) and specify new object
metadata then.
metadata
- The new metadata to set for this object in memory.public S3ObjectInputStream getObjectContent()
Note: The method is a simple getter and does not actually create a stream. If you retrieve an S3Object, you should close this input stream as soon as possible, because the object contents aren't buffered in memory and stream directly from Amazon S3. Further, failure to close this stream can cause the request pool to become blocked.
getObjectMetadata()
,
setObjectContent(InputStream)
public void setObjectContent(S3ObjectInputStream objectContent)
objectContent
- The input stream containing this object's contents.getObjectContent()
public void setObjectContent(java.io.InputStream objectContent)
objectContent
- The input stream containing this object's contents. Will get
wrapped in an S3ObjectInputStream.getObjectContent()
public java.lang.String getBucketName()
setBucketName(String)
public void setBucketName(java.lang.String bucketName)
bucketName
- The name of the bucket containing this object.getBucketName()
public java.lang.String getKey()
setKey(String)
public void setKey(java.lang.String key)
key
- The key under which this object is stored.getKey()
public java.lang.String getRedirectLocation()
public void setRedirectLocation(java.lang.String redirectLocation)
redirectLocation
- the redirect location for that object.public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
- if an I/O error occurspublic boolean isRequesterCharged()
S3RequesterChargedResult
If a bucket is enabled for Requester Pays, then any attempt of operation from it without Requester Pays enabled will result in a 403 error and the bucket owner will be charged for the request.
Enabling Requester Pays disables the ability to have anonymous access to this bucket
isRequesterCharged
in interface S3RequesterChargedResult
public void setRequesterCharged(boolean isRequesterCharged)
S3RequesterChargedResult
If a bucket is enabled for Requester Pays, then any attempt of operation from it without Requester Pays enabled will result in a 403 error and the bucket owner will be charged for the request.
setRequesterCharged
in interface S3RequesterChargedResult
isRequesterCharged
- Indicates requester is charged for this operation.