public class S3ObjectStorageClient extends Object implements ObjectStorageClient
| Constructor and Description |
|---|
S3ObjectStorageClient(String clientKey,
String secretKey,
String region,
String bucketName)
Create a new S3 client for Amazon S3
|
S3ObjectStorageClient(String clientKey,
String secretKey,
String bucketName,
String endpoint,
com.amazonaws.services.s3.S3ClientOptions s3ClientOptions)
Create a new S3 client and specify an endpoint and options
|
S3ObjectStorageClient(String clientKey,
String secretKey,
String region,
String bucketName,
String endpoint)
Create a new S3 client for IBM Cloud/Bluemix.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Terminate all connections and shut down this client
|
com.amazonaws.services.s3.model.Bucket |
createBucket(String bucketName)
Create a new bucket with the provided name and switch to this new bucket
|
void |
delete(String objectName)
Deletes an object, if present.
|
void |
deleteBucket(String bucket)
Delete a bucket (requires admin privileges)
|
Optional<StorageObject> |
get(String objectName)
Gets the
StorageObject including its body. |
Optional<StorageObject> |
get(String objectName,
boolean verify)
Gets the
StorageObject including its body. |
String |
getBucketName() |
byte[] |
getContent(String objectName)
Get the content of the specified object and return it as a byte array.
|
ObjectMetadata |
getMetaData(String id)
Get the metadata of the specified object
|
String |
getName() |
Optional<StorageObject> |
getWithoutBody(String objectName)
Gets the
StorageObject metadata without its body. |
boolean |
isAvailable(String id)
Check if an object with the provided id exists
|
List<StorageObject> |
list() |
List<com.amazonaws.services.s3.model.Bucket> |
listBuckets() |
String |
put(StorageObject storageObject)
Creates or updates a
StorageObject. |
String |
put(String key,
org.jclouds.io.Payload value)
Creates or updates a
StorageObject. |
void |
setEndpoint(String endpoint) |
void |
setS3ClientOptions(com.amazonaws.services.s3.S3ClientOptions s3ClientOptions) |
public S3ObjectStorageClient(String clientKey, String secretKey, String region, String bucketName)
clientKey - secretKey - region - bucketName - public S3ObjectStorageClient(String clientKey, String secretKey, String region, String bucketName, String endpoint)
clientKey - secretKey - region - bucketName - endpoint - public S3ObjectStorageClient(String clientKey, String secretKey, String bucketName, String endpoint, com.amazonaws.services.s3.S3ClientOptions s3ClientOptions)
clientKey - secretKey - bucketName - endpoint - s3ClientOptions - public String getName()
getName in interface ObjectStorageClientObjectStorageClient.getName()public String getBucketName()
getBucketName in interface ObjectStorageClientObjectStorageClient.getBucketName()public List<StorageObject> list()
list in interface ObjectStorageClientList.ObjectStorageClient.list()public boolean isAvailable(String id)
ObjectStorageClientisAvailable in interface ObjectStorageClientObjectStorageClient.isAvailable(String)public void setEndpoint(String endpoint)
public String put(StorageObject storageObject)
ObjectStorageClientStorageObject.put in interface ObjectStorageClientstorageObject - corresponds to StorageObject.getName().StorageObject.getETag() of the object.ObjectStorageClient.put(StorageObject)public String put(String key, org.jclouds.io.Payload value)
ObjectStorageClientStorageObject.put in interface ObjectStorageClientkey - corresponds to StorageObject.getName().value - corresponds to StorageObject.getPayload().StorageObject.getETag() of the object.ObjectStorageClient.put(String, Payload)public Optional<StorageObject> getWithoutBody(String objectName)
ObjectStorageClientStorageObject metadata without its body.getWithoutBody in interface ObjectStorageClientobjectName - corresponds to StorageObject.getName().StorageObject or empty Optional, if not found.ObjectStorageClient.getWithoutBody(String)public Optional<StorageObject> get(String objectName)
ObjectStorageClientStorageObject including its body.
Note that as of version 1.3 we no longer verify if the object was retrieved correctly. To do this you need to use
ObjectStorageClient.get(String, boolean) methodget in interface ObjectStorageClientobjectName - corresponds to StorageObject.getName().StorageObject or empty Optional, if not found.ObjectStorageClient.get(String)public Optional<StorageObject> get(String objectName, boolean verify) throws ContentValidationException
ObjectStorageClientStorageObject including its body.get in interface ObjectStorageClientobjectName - corresponds to StorageObject.getName().verify - if true then the MD5 hash of the downloaded content is compared to the known MD5 hash stored on the
serverStorageObject or empty Optional, if not found.ContentValidationException - thrown when verification of the validity of downloaded content fails.ObjectStorageClient.get(String, boolean)public byte[] getContent(String objectName)
ObjectStorageClientgetContent in interface ObjectStorageClientobjectName - corresponds to StorageObject.getName().ObjectStorageClient.getContent(String)public ObjectMetadata getMetaData(String id)
ObjectStorageClientgetMetaData in interface ObjectStorageClientid - corresponds to StorageObject.getName().ObjectStorageClient.getMetaData(String)public void delete(String objectName)
ObjectStorageClientdelete in interface ObjectStorageClientobjectName - corresponds to StorageObject.getName().ObjectStorageClient.delete(String)public void close()
ObjectStorageClientclose in interface ObjectStorageClientObjectStorageClient.close()public com.amazonaws.services.s3.model.Bucket createBucket(String bucketName)
bucketName - public List<com.amazonaws.services.s3.model.Bucket> listBuckets()
public void deleteBucket(String bucket)
bucket - public void setS3ClientOptions(com.amazonaws.services.s3.S3ClientOptions s3ClientOptions)
Copyright © 2020. All rights reserved.