Class S3JerseyClient
- java.lang.Object
-
- com.emc.object.AbstractJerseyClient
-
- com.emc.object.s3.jersey.S3JerseyClient
-
- All Implemented Interfaces:
S3Client
- Direct Known Subclasses:
S3EncryptionClient
public class S3JerseyClient extends AbstractJerseyClient implements S3Client
Reference implementation of S3Client.This implementation uses the JAX-RS reference implementation (Jersey) as it's REST client. When sending or receiving data, the following content handlers are supported by default. Be sure to use the appropriate content-type associated with each object type or the handlers will not understand the request.
Object Type (class) Expected Content-Type(s) byte[] *any* java.lang.String *any* java.io.File (send-only) *any* java.io.InputStream (send-only) *any* any annotated JAXB root element bean text/xml, application/xml Also keep in mind that you can always send/receive byte[] and do your own conversion.
To use, simply pass a new
S3Config
object to the constructor like so:// for client-side load balancing and direct connection to all nodes // single-VDC (client will auto-discover the remaining nodes): S3Config config1 = new S3Config(Protocol.HTTP, "10.10.10.11", "10.10.10.12"); // multiple VDCs (client will auto-discover remaining nodes in specified VDCs): Vdc boston = new Vdc("10.10.10.11", "10.10.10.12").withName("Boston"); Vdc seattle = new Vdc("10.20.20.11", "10.20.20.12").withName("Seattle"); S3Config config2 = new S3Config(Protocol.HTTPS, boston, seattle); // to use a load balancer will full wildcard DNS setup S3Config config3 = new S3Config(new URI("https://s3.company.com")).withUseVHost(true); // in all cases, you need to provide your credentials configX.withIdentity("my_full_token_id").withSecretKey("my_secret_key"); S3Client s3Client = new S3JerseyClient(configX);
To create an object, simply pass the object in to one of the putObject methods. The object type must be one of the supported types above.
String stringContent = "Hello World!"; s3Client.putObject("my-bucket", "my-key", stringContent, "text/plain"); File fileContent = new File( "spreadsheet.xls" ); s3Client.putObject("my-bucket", "my-data", fileContent, "application/vnd.ms-excel"); byte[] binaryContent; ... // load binary content to store as an object s3Client.putObject("my-bucket", "my-bits", binaryContent, null ); // default content-type is application/octet-stream
To read an object, specify the type of object you want to receive from a readObject method. The same rules apply to this type.
String stringContent = s3Client.readObject("my-bucket", "my-key", String.class); byte[] fileContent = s3Client.readObject("my-bucket", "my-data", byte[].class); // do something with file content (stream to client? save in local filesystem?) byte[] binaryContent = s3Client.readObject("my-bucket", "my-bits", byte[].class);
Performance
If you are experiencing performance issues, you might try tuning Jersey's IO buffer size, which defaults to 8k.
System.setProperty(ReaderWriter.BUFFER_SIZE_SYSTEM_PROPERTY, "" + 128 * 1024); // 128k
You can also try using Jersey's URLConnectionClientHandler, but be aware that this handler does not supportExpect: 100-Continue
behavior if that is important to you. You should also increasehttp.maxConnections
to match your thread count.System.setProperty("http.maxConnections", "" + 32); // if you have 32 threads S3Client s3Client = new S3JerseyClient(configX, new URLConnectionClientHandler());
-
-
Field Summary
Fields Modifier and Type Field Description protected com.sun.jersey.api.client.Client
client
protected com.emc.rest.smart.LoadBalancer
loadBalancer
protected S3Config
s3Config
protected S3Signer
signer
-
Fields inherited from class com.emc.object.AbstractJerseyClient
objectConfig
-
-
Constructor Summary
Constructors Constructor Description S3JerseyClient(S3Config s3Config)
S3JerseyClient(S3Config config, com.sun.jersey.api.client.ClientHandler clientHandler)
Provide a specific Jersey ClientHandler implementation (default is ApacheHttpClient4Handler).
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
abortMultipartUpload(AbortMultipartUploadRequest request)
long
appendObject(java.lang.String bucketName, java.lang.String key, java.lang.Object content)
Atomically appends to the end of objectkey
in bucketbucketName
withcontent
and returns the starting offset of the append operationboolean
bucketExists(java.lang.String bucketName)
Returns whetherbucketName
exists in the user's namespace (or the configured namespace of the client).CompleteMultipartUploadResult
completeMultipartUpload(CompleteMultipartUploadRequest request)
CopyObjectResult
copyObject(CopyObjectRequest request)
Remotely copies an object using the parameters specified inrequest
CopyObjectResult
copyObject(java.lang.String sourceBucketName, java.lang.String sourceKey, java.lang.String bucketName, java.lang.String key)
Remotely copies objectsourceKey
in bucketsourceBucketName
tokey
inbucketName
CopyPartResult
copyPart(CopyPartRequest request)
CopyRangeResult
copyRange(CopyRangeRequest request)
This API is an ECS extension API.void
createBucket(CreateBucketRequest request)
Creates a bucket using the parameters specified inrequest
void
createBucket(java.lang.String bucketName)
Creates a bucket with the specified name in the default namespace and with the default replication groupvoid
deleteBucket(DeleteBucketRequest request)
DeletesbucketName
.void
deleteBucket(java.lang.String bucketName)
DeletesbucketName
.void
deleteBucketCors(java.lang.String bucketName)
Removes the CORS configuration forbucketName
void
deleteBucketLifecycle(java.lang.String bucketName)
Deletes the lifecycle configuration forbucketName
void
deleteBucketPolicy(java.lang.String bucketName)
Deletes the bucket policy forbucketName
void
deleteObject(DeleteObjectRequest request)
Deletes object using the parameters specified inrequest
void
deleteObject(java.lang.String bucketName, java.lang.String key)
Deletes objectkey
from bucketbucketName
DeleteObjectsResult
deleteObjects(DeleteObjectsRequest request)
Deletes objects using the parameters specified inrequest
void
deleteObjectTagging(DeleteObjectTaggingRequest request)
void
deleteVersion(java.lang.String bucketName, java.lang.String key, java.lang.String versionId)
Delets versionversionId
of objectkey
in bucketbucketName
.void
destroy()
Destroy the client.void
enableObjectLock(java.lang.String bucketName)
Enable Object Lock for bucketbucketName
.protected <T> T
executeRequest(com.sun.jersey.api.client.Client client, ObjectRequest request, java.lang.Class<T> responseType)
void
extendRetentionPeriod(java.lang.String bucketName, java.lang.String key, java.lang.Long period)
Extend retentionperiod
(seconds) on objectkey
in bucketbucketName
.protected void
finalize()
AccessControlList
getBucketAcl(java.lang.String bucketName)
Retrieves the ACL ofbucketName
CorsConfiguration
getBucketCors(java.lang.String bucketName)
Retrieves the CORS configuration forbucketName
.BucketDeletionStatus
getBucketDeletionStatus(java.lang.String bucketName)
Gets status of background bucket cleanup tasks forbucketName
if presentBucketInfo
getBucketInfo(java.lang.String bucketName)
Gets information about a bucketLifecycleConfiguration
getBucketLifecycle(java.lang.String bucketName)
Retrieves the lifecycle configuration forbucketName
.LocationConstraint
getBucketLocation(java.lang.String bucketName)
Gets the location ofbucketName
.BucketPolicy
getBucketPolicy(java.lang.String bucketName)
Gets the bucket policy forbucketName
VersioningConfiguration
getBucketVersioning(java.lang.String bucketName)
Retrieves the versioning status ofbucketName
(none, enabled or suspended)com.emc.rest.smart.LoadBalancer
getLoadBalancer()
<T> GetObjectResult<T>
getObject(GetObjectRequest request, java.lang.Class<T> objectType)
Gets an object using the parameters specified inrequest
.GetObjectResult<java.io.InputStream>
getObject(java.lang.String bucketName, java.lang.String key)
Gets objectkey
in bucketbucketName
.AccessControlList
getObjectAcl(GetObjectAclRequest request)
AccessControlList
getObjectAcl(java.lang.String bucketName, java.lang.String key)
ObjectLockLegalHold
getObjectLegalHold(GetObjectLegalHoldRequest request)
Get Object Legal Hold configuration using parameters inrequest
.ObjectLockConfiguration
getObjectLockConfiguration(java.lang.String bucketName)
Get the Object Lock configuration for bucketbucketName
.S3ObjectMetadata
getObjectMetadata(GetObjectMetadataRequest request)
Gets metadata using the parameters specified inrequest
S3ObjectMetadata
getObjectMetadata(java.lang.String bucketName, java.lang.String key)
Gets metadata for objectkey
in bucketbucketName
ObjectLockRetention
getObjectRetention(GetObjectRetentionRequest request)
Get Object Lock Retention using parameters inrequest
.ObjectTagging
getObjectTagging(GetObjectTaggingRequest request)
java.net.URL
getPresignedUrl(PresignedUrlRequest request)
Generates a pre-signed URL using the parameters specified inrequest
java.net.URL
getPresignedUrl(java.lang.String bucketName, java.lang.String key, java.util.Date expirationTime)
Generates a pre-signed URL to read objectkey
in bucketbucketName
.S3Config
getS3Config()
InitiateMultipartUploadResult
initiateMultipartUpload(InitiateMultipartUploadRequest request)
java.lang.String
initiateMultipartUpload(java.lang.String bucketName, java.lang.String key)
MetadataSearchList
listBucketMetadataSearchKeys(java.lang.String bucketName)
Lists the metadata search keys associated with the givne bucket.ListBucketsResult
listBuckets()
Lists the buckets owned by the userListBucketsResult
listBuckets(ListBucketsRequest request)
List the buckets owned by the user using the parameters specified inrequest
ListDataNode
listDataNodes()
Lists all of the data nodes in the current VDCListObjectsResult
listMoreObjects(ListObjectsResult lastResult)
Gets the next page of objects using the results of a previous list-objects callListVersionsResult
listMoreVersions(ListVersionsResult lastResult)
Gets the next page of object versions using the results of a previous list-versions callListMultipartUploadsResult
listMultipartUploads(ListMultipartUploadsRequest request)
ListMultipartUploadsResult
listMultipartUploads(java.lang.String bucketName)
ListObjectsResult
listObjects(ListObjectsRequest request)
Lists objects in a bucket using parameters specified inrequest
ListObjectsResult
listObjects(java.lang.String bucketName)
Lists all objects inbucketName
with no restrictionsListObjectsResult
listObjects(java.lang.String bucketName, java.lang.String prefix)
Lists objects inbucketName
that start withprefix
ListPartsResult
listParts(ListPartsRequest request)
ListPartsResult
listParts(java.lang.String bucketName, java.lang.String key, java.lang.String uploadId)
MetadataSearchList
listSystemMetadataSearchKeys()
Lists the system metadata search keys.ListVersionsResult
listVersions(ListVersionsRequest request)
Lists all versions of all objects in a bucket using the parameters specified inrequest
ListVersionsResult
listVersions(java.lang.String bucketName, java.lang.String prefix)
Lists all versions of all objects inbucketName
that start withprefix
PingResponse
pingNode(Protocol protocol, java.lang.String host, int port)
Issues an unauthenticated ping request to the given host using the given protocol and port.PingResponse
pingNode(java.lang.String host)
Issues an unauthenticated ping request to the specified host.PutObjectResult
putObject(PutObjectRequest request)
Creates or updates an object using the parameters specified inrequest
void
putObject(java.lang.String bucketName, java.lang.String key, Range range, java.lang.Object content)
Updates objectkey
in bucketbucketName
at the specified byterange
with newcontent
void
putObject(java.lang.String bucketName, java.lang.String key, java.lang.Object content, java.lang.String contentType)
Creates or overwrites an object inbucketName
namedkey
containingcontent
and havingcontentType
void
putObjectTagging(PutObjectTaggingRequest request)
QueryObjectsResult
queryMoreObjects(QueryObjectsResult lastResult)
Gets the next page of objects using the results of a previous query-objects callQueryObjectsResult
queryObjects(QueryObjectsRequest request)
Queries objects in a bucket using parameters specified inrequest
<T> T
readObject(java.lang.String bucketName, java.lang.String key, java.lang.Class<T> objectType)
Reads objectkey
in bucketbucketName
and converts it toobjectType
, provided the conversion is supported by the implementation.<T> T
readObject(java.lang.String bucketName, java.lang.String key, java.lang.String versionId, java.lang.Class<T> objectType)
Reads versionversionId
of objectkey
in bucketbucketName
and converts it toobjectType
, provided the conversion is supported by the implementation.java.io.InputStream
readObjectStream(java.lang.String bucketName, java.lang.String key, Range range)
Readsrange
bytes of objectkey
in bucketbucketName
as a stream.void
setBucketAcl(SetBucketAclRequest request)
Sets the ACL of a bucket using parameters inrequest
void
setBucketAcl(java.lang.String bucketName, AccessControlList acl)
Sets the specified ACL onbucketName
void
setBucketAcl(java.lang.String bucketName, CannedAcl cannedAcl)
Sets the specified canned ACL onbucketName
void
setBucketCors(java.lang.String bucketName, CorsConfiguration corsConfiguration)
Sets the CORS configuration forbucketName
void
setBucketLifecycle(java.lang.String bucketName, LifecycleConfiguration lifecycleConfiguration)
Sets the lifecycle configuration forbucketName
void
setBucketPolicy(java.lang.String bucketName, BucketPolicy policy)
Sets the bucket policy forbucketName
void
setBucketStaleReadAllowed(java.lang.String bucketName, boolean staleReadAllowed)
Sets whether stale reads are allowed onbucketName
.void
setBucketVersioning(java.lang.String bucketName, VersioningConfiguration versioningConfiguration)
Enables or suspends versioning onbucketName
void
setObjectAcl(SetObjectAclRequest request)
void
setObjectAcl(java.lang.String bucketName, java.lang.String key, AccessControlList acl)
void
setObjectAcl(java.lang.String bucketName, java.lang.String key, CannedAcl cannedAcl)
void
setObjectLegalHold(SetObjectLegalHoldRequest request)
Set Object Legal Hold configuration using parameters inrequest
.void
setObjectLockConfiguration(java.lang.String bucketName, ObjectLockConfiguration objectLockConfiguration)
Set Object Lock Configuration for bucketbucketName
using parameters inobjectLockConfiguration
.void
setObjectMetadata(java.lang.String bucketName, java.lang.String key, S3ObjectMetadata objectMetadata)
Sets metadata on objectkey
in bucketbucketName
void
setObjectRetention(SetObjectRetentionRequest request)
Set Object Lock Retention using parameters inrequest
.void
shutdown()
Deprecated.(2.0.3) use destroy() insteadMultipartPartETag
uploadPart(UploadPartRequest request)
-
Methods inherited from class com.emc.object.AbstractJerseyClient
buildRequest, executeAndClose, executeRequest, fillResponseEntity, getObjectConfig
-
-
-
-
Constructor Detail
-
S3JerseyClient
public S3JerseyClient(S3Config s3Config)
-
S3JerseyClient
public S3JerseyClient(S3Config config, com.sun.jersey.api.client.ClientHandler clientHandler)
Provide a specific Jersey ClientHandler implementation (default is ApacheHttpClient4Handler). If you experience performance problems, you might try using URLConnectionClientHandler, but note that it will not support the Expect: 100-Continue header and upload size is limited to 2GB. Also note that when using that handler, you should set the "http.maxConnections" system property to match your thread count (default is only 5).
-
-
Method Detail
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
shutdown
public void shutdown()
Deprecated.(2.0.3) use destroy() instead
-
destroy
public void destroy()
Destroy the client. Any system resources associated with the client will be cleaned up.This method must be called when there are not responses pending otherwise undefined behavior will occur.
The client must not be reused after this method is called otherwise undefined behavior will occur.
-
getLoadBalancer
public com.emc.rest.smart.LoadBalancer getLoadBalancer()
-
listDataNodes
public ListDataNode listDataNodes()
Description copied from interface:S3Client
Lists all of the data nodes in the current VDC- Specified by:
listDataNodes
in interfaceS3Client
-
pingNode
public PingResponse pingNode(java.lang.String host)
Description copied from interface:S3Client
Issues an unauthenticated ping request to the specified host.
-
pingNode
public PingResponse pingNode(Protocol protocol, java.lang.String host, int port)
Description copied from interface:S3Client
Issues an unauthenticated ping request to the given host using the given protocol and port.
-
listBuckets
public ListBucketsResult listBuckets()
Description copied from interface:S3Client
Lists the buckets owned by the user- Specified by:
listBuckets
in interfaceS3Client
-
listBuckets
public ListBucketsResult listBuckets(ListBucketsRequest request)
Description copied from interface:S3Client
List the buckets owned by the user using the parameters specified inrequest
- Specified by:
listBuckets
in interfaceS3Client
-
bucketExists
public boolean bucketExists(java.lang.String bucketName)
Description copied from interface:S3Client
Returns whetherbucketName
exists in the user's namespace (or the configured namespace of the client). This call will return true if the bucket exists even if the user does not have access to the bucket. If this call returns false, a subsequent call to createBucket with the same name should succeed- Specified by:
bucketExists
in interfaceS3Client
-
createBucket
public void createBucket(java.lang.String bucketName)
Description copied from interface:S3Client
Creates a bucket with the specified name in the default namespace and with the default replication group- Specified by:
createBucket
in interfaceS3Client
-
createBucket
public void createBucket(CreateBucketRequest request)
Description copied from interface:S3Client
Creates a bucket using the parameters specified inrequest
- Specified by:
createBucket
in interfaceS3Client
- See Also:
CreateBucketRequest
-
getBucketInfo
public BucketInfo getBucketInfo(java.lang.String bucketName)
Description copied from interface:S3Client
Gets information about a bucket- Specified by:
getBucketInfo
in interfaceS3Client
-
deleteBucket
public void deleteBucket(java.lang.String bucketName)
Description copied from interface:S3Client
DeletesbucketName
. The bucket must be empty of all objects and versions before it can be deleted- Specified by:
deleteBucket
in interfaceS3Client
-
deleteBucket
public void deleteBucket(DeleteBucketRequest request)
Description copied from interface:S3Client
DeletesbucketName
. The bucket could contain objects and versions before it can be deleted- Specified by:
deleteBucket
in interfaceS3Client
-
getBucketDeletionStatus
public BucketDeletionStatus getBucketDeletionStatus(java.lang.String bucketName)
Description copied from interface:S3Client
Gets status of background bucket cleanup tasks forbucketName
if present- Specified by:
getBucketDeletionStatus
in interfaceS3Client
-
setBucketAcl
public void setBucketAcl(java.lang.String bucketName, AccessControlList acl)
Description copied from interface:S3Client
Sets the specified ACL onbucketName
- Specified by:
setBucketAcl
in interfaceS3Client
- See Also:
AccessControlList
-
setBucketAcl
public void setBucketAcl(java.lang.String bucketName, CannedAcl cannedAcl)
Description copied from interface:S3Client
Sets the specified canned ACL onbucketName
- Specified by:
setBucketAcl
in interfaceS3Client
- See Also:
CannedAcl
-
setBucketAcl
public void setBucketAcl(SetBucketAclRequest request)
Description copied from interface:S3Client
Sets the ACL of a bucket using parameters inrequest
- Specified by:
setBucketAcl
in interfaceS3Client
- See Also:
SetBucketAclRequest
-
getBucketAcl
public AccessControlList getBucketAcl(java.lang.String bucketName)
Description copied from interface:S3Client
Retrieves the ACL ofbucketName
- Specified by:
getBucketAcl
in interfaceS3Client
- See Also:
AccessControlList
-
setBucketCors
public void setBucketCors(java.lang.String bucketName, CorsConfiguration corsConfiguration)
Description copied from interface:S3Client
Sets the CORS configuration forbucketName
- Specified by:
setBucketCors
in interfaceS3Client
- See Also:
CorsConfiguration
-
getBucketCors
public CorsConfiguration getBucketCors(java.lang.String bucketName)
Description copied from interface:S3Client
Retrieves the CORS configuration forbucketName
. If no CORS configuration exists for the specified bucket,null
is returned- Specified by:
getBucketCors
in interfaceS3Client
- See Also:
CorsConfiguration
-
deleteBucketCors
public void deleteBucketCors(java.lang.String bucketName)
Description copied from interface:S3Client
Removes the CORS configuration forbucketName
- Specified by:
deleteBucketCors
in interfaceS3Client
-
setBucketLifecycle
public void setBucketLifecycle(java.lang.String bucketName, LifecycleConfiguration lifecycleConfiguration)
Description copied from interface:S3Client
Sets the lifecycle configuration forbucketName
- Specified by:
setBucketLifecycle
in interfaceS3Client
- See Also:
LifecycleConfiguration
-
getBucketLifecycle
public LifecycleConfiguration getBucketLifecycle(java.lang.String bucketName)
Description copied from interface:S3Client
Retrieves the lifecycle configuration forbucketName
. If no lifecycle exists for the specified bucket,null
is returned- Specified by:
getBucketLifecycle
in interfaceS3Client
- See Also:
LifecycleConfiguration
-
deleteBucketLifecycle
public void deleteBucketLifecycle(java.lang.String bucketName)
Description copied from interface:S3Client
Deletes the lifecycle configuration forbucketName
- Specified by:
deleteBucketLifecycle
in interfaceS3Client
-
setBucketPolicy
public void setBucketPolicy(java.lang.String bucketName, BucketPolicy policy)
Description copied from interface:S3Client
Sets the bucket policy forbucketName
- Specified by:
setBucketPolicy
in interfaceS3Client
- See Also:
BucketPolicy
-
getBucketPolicy
public BucketPolicy getBucketPolicy(java.lang.String bucketName)
Description copied from interface:S3Client
Gets the bucket policy forbucketName
- Specified by:
getBucketPolicy
in interfaceS3Client
- See Also:
BucketPolicy
-
deleteBucketPolicy
public void deleteBucketPolicy(java.lang.String bucketName)
Description copied from interface:S3Client
Deletes the bucket policy forbucketName
- Specified by:
deleteBucketPolicy
in interfaceS3Client
- See Also:
BucketPolicy
-
getBucketLocation
public LocationConstraint getBucketLocation(java.lang.String bucketName)
Description copied from interface:S3Client
Gets the location ofbucketName
. This call will return the name of the primary VDC of the bucket- Specified by:
getBucketLocation
in interfaceS3Client
-
setBucketVersioning
public void setBucketVersioning(java.lang.String bucketName, VersioningConfiguration versioningConfiguration)
Description copied from interface:S3Client
Enables or suspends versioning onbucketName
- Specified by:
setBucketVersioning
in interfaceS3Client
-
getBucketVersioning
public VersioningConfiguration getBucketVersioning(java.lang.String bucketName)
Description copied from interface:S3Client
Retrieves the versioning status ofbucketName
(none, enabled or suspended)- Specified by:
getBucketVersioning
in interfaceS3Client
-
setBucketStaleReadAllowed
public void setBucketStaleReadAllowed(java.lang.String bucketName, boolean staleReadAllowed)
Description copied from interface:S3Client
Sets whether stale reads are allowed onbucketName
. If true, during a temporary site outage (TSO), objects in the bucket may still be read from secondary sites, but these reads are not guaranteed to be strongly consistent (they may be stale if the primary site is inaccessible). Note that stale reads are not supported onfilesystem
buckets.- Specified by:
setBucketStaleReadAllowed
in interfaceS3Client
-
listSystemMetadataSearchKeys
public MetadataSearchList listSystemMetadataSearchKeys()
Description copied from interface:S3Client
Lists the system metadata search keys.- Specified by:
listSystemMetadataSearchKeys
in interfaceS3Client
-
listBucketMetadataSearchKeys
public MetadataSearchList listBucketMetadataSearchKeys(java.lang.String bucketName)
Description copied from interface:S3Client
Lists the metadata search keys associated with the givne bucket.- Specified by:
listBucketMetadataSearchKeys
in interfaceS3Client
-
queryObjects
public QueryObjectsResult queryObjects(QueryObjectsRequest request)
Description copied from interface:S3Client
Queries objects in a bucket using parameters specified inrequest
- Specified by:
queryObjects
in interfaceS3Client
-
queryMoreObjects
public QueryObjectsResult queryMoreObjects(QueryObjectsResult lastResult)
Description copied from interface:S3Client
Gets the next page of objects using the results of a previous query-objects call- Specified by:
queryMoreObjects
in interfaceS3Client
-
listObjects
public ListObjectsResult listObjects(java.lang.String bucketName)
Description copied from interface:S3Client
Lists all objects inbucketName
with no restrictions- Specified by:
listObjects
in interfaceS3Client
-
listObjects
public ListObjectsResult listObjects(java.lang.String bucketName, java.lang.String prefix)
Description copied from interface:S3Client
Lists objects inbucketName
that start withprefix
- Specified by:
listObjects
in interfaceS3Client
-
listObjects
public ListObjectsResult listObjects(ListObjectsRequest request)
Description copied from interface:S3Client
Lists objects in a bucket using parameters specified inrequest
- Specified by:
listObjects
in interfaceS3Client
-
listMoreObjects
public ListObjectsResult listMoreObjects(ListObjectsResult lastResult)
Description copied from interface:S3Client
Gets the next page of objects using the results of a previous list-objects call- Specified by:
listMoreObjects
in interfaceS3Client
-
listVersions
public ListVersionsResult listVersions(java.lang.String bucketName, java.lang.String prefix)
Description copied from interface:S3Client
Lists all versions of all objects inbucketName
that start withprefix
- Specified by:
listVersions
in interfaceS3Client
-
listVersions
public ListVersionsResult listVersions(ListVersionsRequest request)
Description copied from interface:S3Client
Lists all versions of all objects in a bucket using the parameters specified inrequest
- Specified by:
listVersions
in interfaceS3Client
-
listMoreVersions
public ListVersionsResult listMoreVersions(ListVersionsResult lastResult)
Description copied from interface:S3Client
Gets the next page of object versions using the results of a previous list-versions call- Specified by:
listMoreVersions
in interfaceS3Client
-
putObject
public void putObject(java.lang.String bucketName, java.lang.String key, java.lang.Object content, java.lang.String contentType)
Description copied from interface:S3Client
Creates or overwrites an object inbucketName
namedkey
containingcontent
and havingcontentType
-
putObject
public void putObject(java.lang.String bucketName, java.lang.String key, Range range, java.lang.Object content)
Description copied from interface:S3Client
Updates objectkey
in bucketbucketName
at the specified byterange
with newcontent
-
putObject
public PutObjectResult putObject(PutObjectRequest request)
Description copied from interface:S3Client
Creates or updates an object using the parameters specified inrequest
-
appendObject
public long appendObject(java.lang.String bucketName, java.lang.String key, java.lang.Object content)
Description copied from interface:S3Client
Atomically appends to the end of objectkey
in bucketbucketName
withcontent
and returns the starting offset of the append operation- Specified by:
appendObject
in interfaceS3Client
-
copyObject
public CopyObjectResult copyObject(java.lang.String sourceBucketName, java.lang.String sourceKey, java.lang.String bucketName, java.lang.String key)
Description copied from interface:S3Client
Remotely copies objectsourceKey
in bucketsourceBucketName
tokey
inbucketName
- Specified by:
copyObject
in interfaceS3Client
-
copyObject
public CopyObjectResult copyObject(CopyObjectRequest request)
Description copied from interface:S3Client
Remotely copies an object using the parameters specified inrequest
- Specified by:
copyObject
in interfaceS3Client
-
readObject
public <T> T readObject(java.lang.String bucketName, java.lang.String key, java.lang.Class<T> objectType)
Description copied from interface:S3Client
Reads objectkey
in bucketbucketName
and converts it toobjectType
, provided the conversion is supported by the implementation.Note: this method will return
null
for 304 and 412 responses (failed preconditions).- Specified by:
readObject
in interfaceS3Client
-
readObject
public <T> T readObject(java.lang.String bucketName, java.lang.String key, java.lang.String versionId, java.lang.Class<T> objectType)
Description copied from interface:S3Client
Reads versionversionId
of objectkey
in bucketbucketName
and converts it toobjectType
, provided the conversion is supported by the implementation.Note: this method will return
null
for 304 and 412 responses (failed preconditions).- Specified by:
readObject
in interfaceS3Client
-
readObjectStream
public java.io.InputStream readObjectStream(java.lang.String bucketName, java.lang.String key, Range range)
Description copied from interface:S3Client
Readsrange
bytes of objectkey
in bucketbucketName
as a stream.Note: this method will return
null
for 304 and 412 responses (failed preconditions).- Specified by:
readObjectStream
in interfaceS3Client
-
getObject
public GetObjectResult<java.io.InputStream> getObject(java.lang.String bucketName, java.lang.String key)
Description copied from interface:S3Client
Gets objectkey
in bucketbucketName
. Object details as well as the data stream (obtained fromGetObjectResult.getObject()
are contained in theGetObjectResult
instance.Note: this method will return
null
for 304 and 412 responses (failed preconditions). This method will open a stream for the object data. Be sure to callgetObject()
and, if requesting anInputStream
, properly close the stream to release the connection.
-
getObject
public <T> GetObjectResult<T> getObject(GetObjectRequest request, java.lang.Class<T> objectType)
Description copied from interface:S3Client
Gets an object using the parameters specified inrequest
. Object details as well as the translated data (converted toobjectType
) are contained in theGetObjectResult
instance.Note: this method will return
null
for 304 and 412 responses (failed preconditions). This method will open a stream for the object data. Be sure to callgetObject()
and, if requesting anInputStream
, properly close the stream to release the connection.
-
getPresignedUrl
public java.net.URL getPresignedUrl(java.lang.String bucketName, java.lang.String key, java.util.Date expirationTime)
Description copied from interface:S3Client
Generates a pre-signed URL to read objectkey
in bucketbucketName
. The URL will be valid untilexpirationTime
- Specified by:
getPresignedUrl
in interfaceS3Client
-
getPresignedUrl
public java.net.URL getPresignedUrl(PresignedUrlRequest request)
Description copied from interface:S3Client
Generates a pre-signed URL using the parameters specified inrequest
- Specified by:
getPresignedUrl
in interfaceS3Client
-
deleteObject
public void deleteObject(java.lang.String bucketName, java.lang.String key)
Description copied from interface:S3Client
Deletes objectkey
from bucketbucketName
- Specified by:
deleteObject
in interfaceS3Client
-
deleteObject
public void deleteObject(DeleteObjectRequest request)
Description copied from interface:S3Client
Deletes object using the parameters specified inrequest
- Specified by:
deleteObject
in interfaceS3Client
-
deleteVersion
public void deleteVersion(java.lang.String bucketName, java.lang.String key, java.lang.String versionId)
Description copied from interface:S3Client
Delets versionversionId
of objectkey
in bucketbucketName
.Note: versioning must be enabled in the bucket.
- Specified by:
deleteVersion
in interfaceS3Client
-
deleteObjects
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest request)
Description copied from interface:S3Client
Deletes objects using the parameters specified inrequest
- Specified by:
deleteObjects
in interfaceS3Client
-
setObjectMetadata
public void setObjectMetadata(java.lang.String bucketName, java.lang.String key, S3ObjectMetadata objectMetadata)
Description copied from interface:S3Client
Sets metadata on objectkey
in bucketbucketName
- Specified by:
setObjectMetadata
in interfaceS3Client
-
getObjectMetadata
public S3ObjectMetadata getObjectMetadata(java.lang.String bucketName, java.lang.String key)
Description copied from interface:S3Client
Gets metadata for objectkey
in bucketbucketName
- Specified by:
getObjectMetadata
in interfaceS3Client
-
getObjectMetadata
public S3ObjectMetadata getObjectMetadata(GetObjectMetadataRequest request)
Description copied from interface:S3Client
Gets metadata using the parameters specified inrequest
- Specified by:
getObjectMetadata
in interfaceS3Client
-
setObjectAcl
public void setObjectAcl(java.lang.String bucketName, java.lang.String key, AccessControlList acl)
- Specified by:
setObjectAcl
in interfaceS3Client
-
setObjectAcl
public void setObjectAcl(java.lang.String bucketName, java.lang.String key, CannedAcl cannedAcl)
- Specified by:
setObjectAcl
in interfaceS3Client
-
setObjectAcl
public void setObjectAcl(SetObjectAclRequest request)
- Specified by:
setObjectAcl
in interfaceS3Client
-
getObjectAcl
public AccessControlList getObjectAcl(java.lang.String bucketName, java.lang.String key)
- Specified by:
getObjectAcl
in interfaceS3Client
-
getObjectAcl
public AccessControlList getObjectAcl(GetObjectAclRequest request)
- Specified by:
getObjectAcl
in interfaceS3Client
-
extendRetentionPeriod
public void extendRetentionPeriod(java.lang.String bucketName, java.lang.String key, java.lang.Long period)
Description copied from interface:S3Client
Extend retentionperiod
(seconds) on objectkey
in bucketbucketName
. Note: New retention period value can only be increased. That is, it can be the same as the current or greater value. If the new retention period value is -1, infinite retention applies on that object.- Specified by:
extendRetentionPeriod
in interfaceS3Client
-
listMultipartUploads
public ListMultipartUploadsResult listMultipartUploads(java.lang.String bucketName)
- Specified by:
listMultipartUploads
in interfaceS3Client
-
listMultipartUploads
public ListMultipartUploadsResult listMultipartUploads(ListMultipartUploadsRequest request)
- Specified by:
listMultipartUploads
in interfaceS3Client
-
initiateMultipartUpload
public java.lang.String initiateMultipartUpload(java.lang.String bucketName, java.lang.String key)
- Specified by:
initiateMultipartUpload
in interfaceS3Client
-
initiateMultipartUpload
public InitiateMultipartUploadResult initiateMultipartUpload(InitiateMultipartUploadRequest request)
- Specified by:
initiateMultipartUpload
in interfaceS3Client
-
listParts
public ListPartsResult listParts(java.lang.String bucketName, java.lang.String key, java.lang.String uploadId)
-
listParts
public ListPartsResult listParts(ListPartsRequest request)
-
uploadPart
public MultipartPartETag uploadPart(UploadPartRequest request)
- Specified by:
uploadPart
in interfaceS3Client
-
copyPart
public CopyPartResult copyPart(CopyPartRequest request)
-
completeMultipartUpload
public CompleteMultipartUploadResult completeMultipartUpload(CompleteMultipartUploadRequest request)
- Specified by:
completeMultipartUpload
in interfaceS3Client
-
abortMultipartUpload
public void abortMultipartUpload(AbortMultipartUploadRequest request)
- Specified by:
abortMultipartUpload
in interfaceS3Client
-
setObjectLockConfiguration
public void setObjectLockConfiguration(java.lang.String bucketName, ObjectLockConfiguration objectLockConfiguration)
Description copied from interface:S3Client
Set Object Lock Configuration for bucketbucketName
using parameters inobjectLockConfiguration
.- Specified by:
setObjectLockConfiguration
in interfaceS3Client
-
getObjectLockConfiguration
public ObjectLockConfiguration getObjectLockConfiguration(java.lang.String bucketName)
Description copied from interface:S3Client
Get the Object Lock configuration for bucketbucketName
. If Object Lock Configuration is not set,null
is returned.- Specified by:
getObjectLockConfiguration
in interfaceS3Client
-
enableObjectLock
public void enableObjectLock(java.lang.String bucketName)
Description copied from interface:S3Client
Enable Object Lock for bucketbucketName
.- Specified by:
enableObjectLock
in interfaceS3Client
-
setObjectLegalHold
public void setObjectLegalHold(SetObjectLegalHoldRequest request)
Description copied from interface:S3Client
Set Object Legal Hold configuration using parameters inrequest
.- Specified by:
setObjectLegalHold
in interfaceS3Client
-
getObjectLegalHold
public ObjectLockLegalHold getObjectLegalHold(GetObjectLegalHoldRequest request)
Description copied from interface:S3Client
Get Object Legal Hold configuration using parameters inrequest
.- Specified by:
getObjectLegalHold
in interfaceS3Client
-
setObjectRetention
public void setObjectRetention(SetObjectRetentionRequest request)
Description copied from interface:S3Client
Set Object Lock Retention using parameters inrequest
.- Specified by:
setObjectRetention
in interfaceS3Client
-
getObjectRetention
public ObjectLockRetention getObjectRetention(GetObjectRetentionRequest request)
Description copied from interface:S3Client
Get Object Lock Retention using parameters inrequest
.- Specified by:
getObjectRetention
in interfaceS3Client
-
copyRange
public CopyRangeResult copyRange(CopyRangeRequest request)
Description copied from interface:S3Client
This API is an ECS extension API. IN addition to standard UploadPartCopy, it can source from multiple objects and reference ranges inside those objects. And it can work though with many Internet proxy servers, web servers (ECS included), and load balancers which may have a limit on HTTP headers.
-
getObjectTagging
public ObjectTagging getObjectTagging(GetObjectTaggingRequest request)
- Specified by:
getObjectTagging
in interfaceS3Client
-
putObjectTagging
public void putObjectTagging(PutObjectTaggingRequest request)
- Specified by:
putObjectTagging
in interfaceS3Client
-
deleteObjectTagging
public void deleteObjectTagging(DeleteObjectTaggingRequest request)
- Specified by:
deleteObjectTagging
in interfaceS3Client
-
executeRequest
protected <T> T executeRequest(com.sun.jersey.api.client.Client client, ObjectRequest request, java.lang.Class<T> responseType)
- Overrides:
executeRequest
in classAbstractJerseyClient
-
getS3Config
public S3Config getS3Config()
-
-