@Component public class FileStore extends Object
| Constructor and Description |
|---|
FileStore(String rootDirectory)
Constructs a new
FileStore. |
| Modifier and Type | Method and Description |
|---|---|
void |
abortMultipartUpload(String bucketName,
String fileName,
String uploadId)
Aborts the upload.
|
String |
completeMultipartUpload(String bucketName,
String fileName,
String uploadId)
Finishes the upload.
|
String |
completeMultipartUpload(String bucketName,
String fileName,
String uploadId,
String encryption,
String kmsKeyId)
Completes an Multipart Upload for the given Id.
|
String |
copyPart(String bucket,
String key,
int from,
int to,
String partNumber,
String destinationBucket,
String destinationFilename,
String uploadId)
Copies the range, define by from/to, from the S3 Object, identified by the given key to given
destination into the given bucket.
|
CopyObjectResult |
copyS3Object(String sourceBucketName,
String sourceObjectName,
String destinationBucketName,
String destinationObjectName)
Copies an object, identified by bucket and name, to a another bucket and objectName.
|
CopyObjectResult |
copyS3ObjectEncrypted(String sourceBucketName,
String sourceObjectName,
String destinationBucketName,
String destinationObjectName,
String encryption,
String kmsKeyId)
Copies an object to another bucket and encrypted object.
|
Bucket |
createBucket(String bucketName)
Creates a new bucket.
|
boolean |
deleteBucket(String bucketName)
Deletes a Bucket and all of its contents.
|
boolean |
deleteObject(String bucketName,
String objectName)
Removes an object from a bucket.
|
Boolean |
doesBucketExist(String bucketName)
Checks if the specified bucket exists.
|
Bucket |
getBucket(String bucketName)
Retrieves a bucket identified by its name.
|
List<Part> |
getMultipartUploadParts(String bucketName,
String fileName,
String uploadId)
Get all multipart upload parts.
|
S3Object |
getS3Object(String bucketName,
String objectName)
Retrieves an Object from a bucket.
|
List<S3Object> |
getS3Objects(String bucketName,
String prefix)
Retrieves list of Objects from a bucket.
|
List<Bucket> |
listBuckets()
Lists all buckets managed by this FileStore.
|
Collection<MultipartUpload> |
listMultipartUploads()
Lists the not-yet completed parts of an multipart upload.
|
MultipartUpload |
prepareMultipartUpload(String bucketName,
String fileName,
String contentType,
String contentEncoding,
String uploadId,
Owner owner,
Owner initiator)
Prepares everything to store files uploaded as multipart upload.
|
MultipartUpload |
prepareMultipartUpload(String bucketName,
String fileName,
String contentType,
String contentEncoding,
String uploadId,
Owner owner,
Owner initiator,
Map<String,String> userMetadata)
Prepares everything to store files uploaded as multipart upload.
|
String |
putPart(String bucketName,
String fileName,
String uploadId,
String partNumber,
InputStream inputStream,
boolean useV4ChunkedWithSigningFormat)
Uploads a part of a multipart upload.
|
S3Object |
putS3Object(String bucketName,
String fileName,
String contentType,
String contentEncoding,
InputStream dataStream,
boolean useV4ChunkedWithSigningFormat)
Stores a File inside a Bucket.
|
S3Object |
putS3Object(String bucketName,
String fileName,
String contentType,
String contentEncoding,
InputStream dataStream,
boolean useV4ChunkedWithSigningFormat,
Map<String,String> userMetadata)
Stores a File inside a Bucket.
|
S3Object |
putS3ObjectWithKMSEncryption(String bucketName,
String fileName,
String contentType,
InputStream dataStream,
boolean useV4ChunkedWithSigningFormat,
Map<String,String> userMetadata,
String encryption,
String kmsKeyId)
Stores an encrypted File inside a Bucket.
|
S3Object |
putS3ObjectWithKMSEncryption(String bucketName,
String fileName,
String contentType,
InputStream dataStream,
boolean useV4Signing,
String encryption,
String kmsKeyId)
Stores an encrypted File inside a Bucket.
|
void |
setObjectTags(String bucketName,
String fileName,
List<Tag> tags)
Sets tags for a given object.
|
public Bucket createBucket(String bucketName) throws IOException
bucketName - name of the Bucket to be created.IOException - if the bucket cannot be created or the bucket already exists but is not
a directory.public List<Bucket> listBuckets()
public Bucket getBucket(String bucketName)
bucketName - name of the bucket to be retrievedpublic S3Object putS3Object(String bucketName, String fileName, String contentType, String contentEncoding, InputStream dataStream, boolean useV4ChunkedWithSigningFormat) throws IOException
bucketName - Bucket to store the File in.fileName - name of the File to be stored.contentType - The files Content Type.contentEncoding - The files Content Encoding.dataStream - The File as InputStream.useV4ChunkedWithSigningFormat - If true, V4-style signing is enabled.S3Object.IOException - if an I/O error occurs.public S3Object putS3Object(String bucketName, String fileName, String contentType, String contentEncoding, InputStream dataStream, boolean useV4ChunkedWithSigningFormat, Map<String,String> userMetadata) throws IOException
bucketName - Bucket to store the File in.fileName - name of the File to be stored.contentType - The files Content Type.contentEncoding - The files Content Encoding.dataStream - The File as InputStream.useV4ChunkedWithSigningFormat - If true, V4-style signing is enabled.userMetadata - User metadata to store for this object, will be available for the
object with the key prefixed with "x-amz-meta-".S3Object.IOException - if an I/O error occurs.public S3Object putS3ObjectWithKMSEncryption(String bucketName, String fileName, String contentType, InputStream dataStream, boolean useV4Signing, String encryption, String kmsKeyId) throws IOException
bucketName - Bucket to store the File in.fileName - name of the File to be stored.contentType - The files Content Type.dataStream - The File as InputStream.useV4Signing - If true, V4-style signing is enabled.encryption - The Encryption Type.kmsKeyId - The KMS encryption key id.S3Object.IOException - if an I/O error occurs.public S3Object putS3ObjectWithKMSEncryption(String bucketName, String fileName, String contentType, InputStream dataStream, boolean useV4ChunkedWithSigningFormat, Map<String,String> userMetadata, String encryption, String kmsKeyId) throws IOException
bucketName - Bucket to store the File in.fileName - name of the File to be stored.contentType - The files Content Type.dataStream - The File as InputStream.useV4ChunkedWithSigningFormat - If true, V4-style signing is enabled.userMetadata - User metadata to store for this object, will be available for the
object with the key prefixed with "x-amz-meta-".encryption - The Encryption Type.kmsKeyId - The KMS encryption key id.S3Object.IOException - if an I/O error occurs.public void setObjectTags(String bucketName, String fileName, List<Tag> tags) throws IOException
bucketName - Bucket where the file is stored in.fileName - name of the file to which tags have to be attached.tags - List of tag objects.IOException - if an I/O error occurs.public S3Object getS3Object(String bucketName, String objectName)
bucketName - the Bucket in which to look the file in.objectName - name of the object.public List<S3Object> getS3Objects(String bucketName, String prefix) throws IOException
bucketName - the Bucket in which to list the file(s) in.prefix - String object file name starts withList<S3Object> or null if not foundIOException - if directory stream failspublic CopyObjectResult copyS3Object(String sourceBucketName, String sourceObjectName, String destinationBucketName, String destinationObjectName) throws IOException
sourceBucketName - name of the bucket to copy from.sourceObjectName - name of the object to copy.destinationBucketName - name of the destination bucket.destinationObjectName - name of the destination object.CopyObjectResult or null if source couldn't be found.FileNotFoundException - no FileInputStream of the sourceFile can be created.IOException - If File can't be read.public CopyObjectResult copyS3ObjectEncrypted(String sourceBucketName, String sourceObjectName, String destinationBucketName, String destinationObjectName, String encryption, String kmsKeyId) throws IOException
sourceBucketName - name of the bucket to copy from.sourceObjectName - name of the object to copy.destinationBucketName - name of the destination bucket.destinationObjectName - name of the destination object.encryption - The Encryption Type.kmsKeyId - The KMS encryption key id.CopyObjectResult or null if source couldn't be found.FileNotFoundException - no FileInputStream of the sourceFile can be created.IOException - If File can't be read.public Boolean doesBucketExist(String bucketName)
bucketName - Name of the bucket to check for existencepublic boolean deleteObject(String bucketName, String objectName) throws IOException
bucketName - name of the bucket containing the object.objectName - name of the object to be deleted.IOException - if File could not be accessed.public boolean deleteBucket(String bucketName) throws IOException
bucketName - name of the bucket to be deleted.IOException - if bucket-file could not be accessed.public MultipartUpload prepareMultipartUpload(String bucketName, String fileName, String contentType, String contentEncoding, String uploadId, Owner owner, Owner initiator, Map<String,String> userMetadata)
bucketName - in which to uploadfileName - of the file to uploadcontentType - the content typecontentEncoding - the content encodinguploadId - id of the uploadowner - owner of the uploadinitiator - initiator of the uploaduserMetadata - custom metadatapublic MultipartUpload prepareMultipartUpload(String bucketName, String fileName, String contentType, String contentEncoding, String uploadId, Owner owner, Owner initiator)
bucketName - in which to uploadfileName - of the file to uploadcontentType - the content typecontentEncoding - the content encodinguploadId - id of the uploadowner - owner of the uploadinitiator - initiator of the uploadpublic Collection<MultipartUpload> listMultipartUploads()
public void abortMultipartUpload(String bucketName, String fileName, String uploadId)
bucketName - to which was uploadedfileName - which was uploadeduploadId - of the uploadpublic String putPart(String bucketName, String fileName, String uploadId, String partNumber, InputStream inputStream, boolean useV4ChunkedWithSigningFormat) throws IOException
bucketName - in which to uploadfileName - of the file to uploaduploadId - id of the uploadpartNumber - number of the part to storeinputStream - file data to be storeduseV4ChunkedWithSigningFormat - If true, V4-style signing is enabled.IOException - if file could not be read to calculate digestpublic String completeMultipartUpload(String bucketName, String fileName, String uploadId)
bucketName - to which was uploaded.fileName - which was uploaded.uploadId - of the upload.public String completeMultipartUpload(String bucketName, String fileName, String uploadId, String encryption, String kmsKeyId)
bucketName - in which to upload.fileName - of the file to upload.uploadId - id of the upload.encryption - The Encryption Type.kmsKeyId - The KMS encryption key id.public List<Part> getMultipartUploadParts(String bucketName, String fileName, String uploadId)
bucketName - name of the bucketfileName - name of the file (object key)uploadId - upload identifierpublic String copyPart(String bucket, String key, int from, int to, String partNumber, String destinationBucket, String destinationFilename, String uploadId) throws IOException
bucket - The source Bucket.key - Identifies the S3 Object.from - Byte range form.to - Byte range to.partNumber - The part to copy.destinationBucket - The Bucket the target file (will) reside in.destinationFilename - The target file.uploadId - id of the upload.IOException - When writing the file fails.Copyright © 2019 Adobe. All rights reserved.