public class

S3Object

extends Object
implements Closeable
java.lang.Object
   ↳ org.mule.module.s3.model.S3Object

Class Overview

Represents an object stored in Amazon S3. This object contains the data content and the object metadata stored by Amazon S3, such as content type, content length, etc.

See Also

Summary

Fields
private 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 String key The key under which this object is stored
private S3ObjectMetadata metadata The metadata stored by Amazon S3 for this object
private S3ObjectInputStream objectContent The stream containing the contents of this object from S3
private String redirectLocation The redirect location for this object
Public Constructors
S3Object()
Public Methods
void close()
Releases any underlying system resources.
String getBucketName()
Gets the name of the bucket in which this object is contained.
String getKey()
Gets the key under which this object is stored.
S3ObjectInputStream getObjectContent()
Gets the input stream containing the contents of this object.
S3ObjectMetadata getObjectMetadata()
Gets the metadata stored by Amazon S3 for this object.
String getRedirectLocation()
Gets the redirect location for this object.
boolean isRequesterCharged()
Returns true if the user is charged for downloading the object from an Requester Pays Bucket; else false.
void setBucketName(String bucketName)
Sets the name of the bucket in which this object is contained.
void setKey(String key)
Sets the key under which this object is stored.
void setObjectContent(S3ObjectInputStream objectContent)
Sets the input stream containing this object's contents.
void setObjectMetadata(S3ObjectMetadata 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 downloading an Amazon S3 Object from a Requester Pays Bucket.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Fields

private 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 String key

The key under which this object is stored

private S3ObjectMetadata metadata

The metadata stored by Amazon S3 for this object

private S3ObjectInputStream objectContent

The stream containing the contents of this object from S3

private String redirectLocation

The redirect location for this object

Public Constructors

public S3Object ()

Public Methods

public void close ()

Releases any underlying system resources. If the resources are already released then invoking this method has no effect.

Throws
IOException if an I/O error occurs

public String 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.

public String getKey ()

Gets the key under which this object is stored.

Returns
  • The key under which this object is stored.
See Also

public S3ObjectInputStream 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.

public S3ObjectMetadata getObjectMetadata ()

Gets the metadata stored by Amazon S3 for this object. The S3ObjectMetadata 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.

public String getRedirectLocation ()

Gets the redirect location for this object.

public boolean isRequesterCharged ()

Returns true if the user is charged for downloading the object from an Requester Pays Bucket; else false.

If a bucket is enabled for Requester Pays, then any attempt to read an object from it without Requester Pays enabled will result in a 403 error and the bucket owner will be charged for the request.

Returns
  • true if the user has been charged for the download operation from Requester Pays Bucket.

public void setBucketName (String bucketName)

Sets the name of the bucket in which this object is contained.

Parameters
bucketName The name of the bucket containing this object.
See Also

public void setKey (String key)

Sets the key under which this object is stored.

Parameters
key The key under which this object is stored.
See Also

public void setObjectContent (S3ObjectInputStream objectContent)

Sets the input stream containing this object's contents.

Parameters
objectContent The input stream containing this object's contents.

public void setObjectMetadata (S3ObjectMetadata metadata)

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 copyObject(String, String, String, String, String, CannedAccessControlList, StorageClass, Map, Date, Date, String) 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.

public void setRedirectLocation (String redirectLocation)

Sets the redirect location for this object.

Parameters
redirectLocation The redirect location for that object.

public void setRequesterCharged (boolean isRequesterCharged)

Used for downloading an Amazon S3 Object from a Requester Pays Bucket. If set the requester is charged for downloading the data from the bucket.

If a bucket is enabled for Requester Pays, then any attempt to read an object from it without Requester Pays enabled will result in a 403 error and the bucket owner will be charged for the request.

Parameters
isRequesterCharged Indicates requester is charged for this operation.

public String toString ()

See Also