Class S3Object
- All Implemented Interfaces:
com.amazonaws.services.s3.internal.S3RequesterChargedResult
,Closeable
,Serializable
,AutoCloseable
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Releases any underlying system resources.Gets the name of the bucket in which this object is contained.getKey()
Gets the key under which this object is stored.Gets the input stream containing the contents of this object.Gets the metadata stored by Amazon S3 for this object.Gets the redirect location for this object.boolean
Returns true if the user has enabled Requester Pays option when conducting this operation from Requester Pays Bucket; else false.void
setBucketName
(String bucketName) Sets the name of the bucket in which this object is contained.void
Sets the key under which this object is stored.void
setObjectContent
(S3ObjectInputStream objectContent) Sets the input stream containing this object's contents.void
setObjectContent
(InputStream objectContent) Sets the input stream containing this object's contents.void
setObjectMetadata
(ObjectMetadata metadata) Sets the object metadata for this object.void
setRedirectLocation
(String redirectLocation) Sets the redirect location for this object.void
setRequesterCharged
(boolean isRequesterCharged) Used for conducting this operation from a Requester Pays Bucket.toString()
-
Constructor Details
-
S3Object
public S3Object()
-
-
Method Details
-
getObjectMetadata
Gets the metadata stored by Amazon S3 for this object. TheObjectMetadata
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.- Returns:
- The metadata stored by Amazon S3 for this object.
- See Also:
-
setObjectMetadata
Sets the object metadata for this object.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.- Parameters:
metadata
- The new metadata to set for this object in memory.
-
getObjectContent
Gets the input stream containing the contents of this object.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.
- Returns:
- An input stream containing the contents of this object.
- See Also:
-
setObjectContent
Sets the input stream containing this object's contents.- Parameters:
objectContent
- The input stream containing this object's contents.- See Also:
-
setObjectContent
Sets the input stream containing this object's contents.- Parameters:
objectContent
- The input stream containing this object's contents. Will get wrapped in an S3ObjectInputStream.- See Also:
-
getBucketName
Gets the name of the bucket in which this object is contained.- Returns:
- The name of the bucket in which this object is contained.
- See Also:
-
setBucketName
Sets the name of the bucket in which this object is contained.- Parameters:
bucketName
- The name of the bucket containing this object.- See Also:
-
getKey
Gets the key under which this object is stored.- Returns:
- The key under which this object is stored.
- See Also:
-
setKey
Sets the key under which this object is stored.- Parameters:
key
- The key under which this object is stored.- See Also:
-
getRedirectLocation
Gets the redirect location for this object. -
setRedirectLocation
Sets the redirect location for this object.- Parameters:
redirectLocation
- the redirect location for that object.
-
toString
-
close
Releases any underlying system resources. If the resources are already released then invoking this method has no effect.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an I/O error occurs
-
isRequesterCharged
public boolean isRequesterCharged()Description copied from interface:com.amazonaws.services.s3.internal.S3RequesterChargedResult
Returns true if the user has enabled Requester Pays option when conducting this operation from Requester Pays Bucket; else false.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
- Specified by:
isRequesterCharged
in interfacecom.amazonaws.services.s3.internal.S3RequesterChargedResult
- Returns:
- true if the user has enabled Requester Pays option for conducting this operation from Requester Pays Bucket.
-
setRequesterCharged
public void setRequesterCharged(boolean isRequesterCharged) Description copied from interface:com.amazonaws.services.s3.internal.S3RequesterChargedResult
Used for conducting this operation from a Requester Pays Bucket. If set the requester is charged for conducting the operation from the bucket.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.
- Specified by:
setRequesterCharged
in interfacecom.amazonaws.services.s3.internal.S3RequesterChargedResult
- Parameters:
isRequesterCharged
- Indicates requester is charged for this operation.
-