public abstract class AbstractAmazonS3Operations extends java.lang.Object implements AmazonS3Operations, org.springframework.beans.factory.InitializingBean
AmazonS3Operations. The sub class
has to implement all the functionality for performing the actual work to add, remove, update
delete, list the objects in an S3 bucket| Modifier and Type | Field and Description |
|---|---|
protected org.apache.commons.logging.Log |
logger |
java.lang.String |
PATH_SEPARATOR |
CONTENT_MD5_HEADER| Modifier | Constructor and Description |
|---|---|
protected |
AbstractAmazonS3Operations(AWSCredentials credentials)
The constructor that accepts the
AWSCredentials |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
The implemented afterPropertiesSet method
|
protected abstract AmazonS3Object |
doGetObject(java.lang.String bucketName,
java.lang.String key)
Gets the object from the given bucket with the given key using the AWS SDK implementation
|
protected abstract PaginatedObjectsView |
doListObjects(java.lang.String bucketName,
java.lang.String nextMarker,
int pageSize,
java.lang.String prefix)
The implementation should use the appropriate API to list objects from the given bucket
|
protected abstract void |
doPut(java.lang.String bucket,
java.lang.String key,
java.io.File file,
AmazonS3ObjectACL objectACL,
java.util.Map<java.lang.String,java.lang.String> userMetadata,
java.lang.String stringContentMD5)
The abstract method to be implemented by the subclass that would be doing the job
of uploading the given file against the given key in the given bucket
|
java.lang.String |
getAwsEndpoint()
Gets the AWS endpoint to use for all the operations, by default if none is set then us-east-1 is
assumed.
|
long |
getMultipartUploadThreshold()
Get the threshold value in bytes above which multi part upload will be used
|
AmazonS3Object |
getObject(java.lang.String bucketName,
java.lang.String folder,
java.lang.String objectName)
Gets the object from the given bucket, folder and the name.
|
java.io.File |
getTemporaryDirectory()
Gets the temporary directory
|
java.lang.String |
getTemporaryFileSuffix()
Gets the temporary file suffix that is appended to the file while writing to
the temporary directory
|
protected void |
init()
The subclass needs to override this method if it desires to perform any initializing
of the class
|
PaginatedObjectsView |
listObjects(java.lang.String bucketName,
java.lang.String folder,
java.lang.String nextMarker,
int pageSize)
List the objects in a given bucket in the given folder.
|
void |
putObject(java.lang.String bucketName,
java.lang.String folder,
java.lang.String objectName,
AmazonS3Object s3Object)
The implementation of the core common operations that would be performed
before and after the subclass does the actual work of putting the object to
the given bucket
|
boolean |
removeObject(java.lang.String bucketName,
java.lang.String folder,
java.lang.String objectName)
Deletes the object with the given name from the provided bucket and folder.
|
void |
setAwsEndpoint(java.lang.String awsEndpoint)
Sets the valid AWS endpoint to be used by the client to connect to appropriate
region to perform the operations
|
void |
setMultipartUploadThreshold(long multipartUploadThreshold)
The threshold value in bytes above which the service will use multi part upload.
|
void |
setTemporaryDirectory(java.io.File temporaryDirectory)
The temporary directory that will be used to write the files received over stream
|
void |
setTemporaryDirectory(java.lang.String temporaryDirectory)
The temporary directory that will be used to write the files received over stream
|
void |
setTemporaryFileSuffix(java.lang.String temporaryFileSuffix)
Gets the temporary file suffix
|
protected final org.apache.commons.logging.Log logger
public final java.lang.String PATH_SEPARATOR
protected AbstractAmazonS3Operations(AWSCredentials credentials)
AWSCredentialscredentials - public long getMultipartUploadThreshold()
public void setMultipartUploadThreshold(long multipartUploadThreshold)
multipartUploadThreshold - public java.io.File getTemporaryDirectory()
public void setTemporaryDirectory(java.io.File temporaryDirectory)
temporaryDirectory - public void setTemporaryDirectory(java.lang.String temporaryDirectory)
temporaryDirectory - public java.lang.String getTemporaryFileSuffix()
public void setTemporaryFileSuffix(java.lang.String temporaryFileSuffix)
temporaryFileSuffix - public java.lang.String getAwsEndpoint()
public void setAwsEndpoint(java.lang.String awsEndpoint)
awsEndpoint - public final void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionprotected void init()
public final void putObject(java.lang.String bucketName,
java.lang.String folder,
java.lang.String objectName,
AmazonS3Object s3Object)
putObject in interface AmazonS3OperationsbucketName - The bucket to which the object is to be putfolder - The folder to which the object is to be uploadedobjectName - The name of the object in the given buckets3Object - The AmazonS3Object instance that represents the object
to be uploaded.public boolean removeObject(java.lang.String bucketName,
java.lang.String folder,
java.lang.String objectName)
removeObject in interface AmazonS3Operationspublic final PaginatedObjectsView listObjects(java.lang.String bucketName, java.lang.String folder, java.lang.String nextMarker, int pageSize)
listObjects in interface AmazonS3OperationsbucketName - The bucket in which we want to list the objects innextMarker - The number of objects can be very large and this serves as the marker
for remembering the last record fetch in the last retrieve operation.pageSize - The max number of records to be retrieved in one list object operation.PaginatedObjectsView of the matching resultpublic final AmazonS3Object getObject(java.lang.String bucketName, java.lang.String folder, java.lang.String objectName)
getObject in interface AmazonS3OperationsbucketName - The bucket from which to retrieve the objectfolder - The folder nameobjectName - The name of the object to retrieveprotected abstract AmazonS3Object doGetObject(java.lang.String bucketName, java.lang.String key)
bucketName - key - protected abstract PaginatedObjectsView doListObjects(java.lang.String bucketName, java.lang.String nextMarker, int pageSize, java.lang.String prefix)
bucketName - The bucket in which we want to list the objects innextMarker - The number of objects can be very large and this serves as the marker
for remembering the last record fetch in the last retrieve operation.pageSize - The max number of records to be retrieved in one list object operation.prefix - The prefix for the list operation, this can serve as the folder whose contents
are to be listed.protected abstract void doPut(java.lang.String bucket,
java.lang.String key,
java.io.File file,
AmazonS3ObjectACL objectACL,
java.util.Map<java.lang.String,java.lang.String> userMetadata,
java.lang.String stringContentMD5)
bucket - The bucket on S3 where this object is to be putkey - The key against which this Object is to be stored in S3file - resource to be uploaded to S3objectACL - the Object's Access controls for the object to be uploadeduserMetadata - The user's metadata to be associated with the object uploadedstringContentMD5 - The MD5 sum of the contents of the file to be uploaded