Class AwsBlobStore
- java.lang.Object
-
- com.salesforce.multicloudj.blob.driver.AbstractBlobStore<AwsBlobStore>
-
- com.salesforce.multicloudj.blob.aws.AwsBlobStore
-
- All Implemented Interfaces:
BlobStore
,Provider
,SdkService
@AutoService(AbstractBlobStore.class) public class AwsBlobStore extends AbstractBlobStore<AwsBlobStore>
AWS implementation of BlobStore
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AwsBlobStore.Builder
-
Field Summary
-
Fields inherited from class com.salesforce.multicloudj.blob.driver.AbstractBlobStore
bucket, credentialsOverrider, region, validator
-
-
Constructor Summary
Constructors Constructor Description AwsBlobStore()
AwsBlobStore(AwsBlobStore.Builder builder, software.amazon.awssdk.services.s3.S3Client s3Client)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AwsBlobStore.Builder
builder()
Creates and returns a new Builder instance for this provider.protected void
doAbortMultipartUpload(MultipartUpload mpu)
Aborts a multipartUpload that's in progressprotected MultipartUploadResponse
doCompleteMultipartUpload(MultipartUpload mpu, List<UploadPartResponse> parts)
Completes a multipartUpload operationprotected CopyResponse
doCopy(CopyRequest request)
Copies a Blob to a different bucketprotected void
doDelete(String key, String versionId)
Deletes a single Blobprotected void
doDelete(Collection<BlobIdentifier> objects)
Deletes a collection of Blobsprotected boolean
doDoesObjectExist(String key, String versionId)
Determines if an object exists for a given key/versionIdprotected DownloadResponse
doDownload(DownloadRequest downloadRequest, ByteArray byteArray)
Performs Blob downloadprotected DownloadResponse
doDownload(DownloadRequest downloadRequest, File file)
Performs Blob downloadprotected DownloadResponse
doDownload(DownloadRequest downloadRequest, OutputStream outputStream)
Performs Blob downloadprotected DownloadResponse
doDownload(DownloadRequest downloadRequest, Path path)
Performs Blob downloadprotected URL
doGeneratePresignedUrl(PresignedUrlRequest request)
Generates a presigned URL for uploading/downloading blobsprotected BlobMetadata
doGetMetadata(String key, String versionId)
Retrieves the Blob metadataprotected Map<String,String>
doGetTags(String key)
Returns a map of all the tags associated with the blobprotected MultipartUpload
doInitiateMultipartUpload(MultipartUploadRequest request)
Initiates a multipart uploadprotected Iterator<BlobInfo>
doList(ListBlobsRequest request)
Lists all objects in the bucketprotected List<UploadPartResponse>
doListMultipartUpload(MultipartUpload mpu)
List all parts that have been uploaded for the multipartUpload so farprotected void
doSetTags(String key, Map<String,String> tags)
Sets tags on a blobprotected UploadResponse
doUpload(UploadRequest uploadRequest, byte[] content)
Performs Blob uploadprotected UploadResponse
doUpload(UploadRequest uploadRequest, File file)
Performs Blob uploadprotected UploadResponse
doUpload(UploadRequest uploadRequest, InputStream inputStream)
Performs Blob upload Note: Specifying the contentLength in the UploadRequest can dramatically improve upload efficiency because the substrate SDKs do not need to buffer the contents and calculate it themselves.protected UploadResponse
doUpload(UploadRequest uploadRequest, Path path)
Performs Blob uploadprotected UploadResponse
doUpload(UploadRequest uploadRequest, software.amazon.awssdk.core.sync.RequestBody requestBody)
Helper function to upload blobsprotected UploadPartResponse
doUploadMultipartPart(MultipartUpload mpu, MultipartPart mpp)
Uploads a part of the multipartUpload operationClass<? extends SubstrateSdkException>
getException(Throwable t)
Maps a given Throwable from the provider implementation to a specific SubstrateSdkException.protected software.amazon.awssdk.services.s3.presigner.S3Presigner
getPresigner()
Returns an S3Presigner for the current credentialsprotected static boolean
shouldConfigureHttpClient(AwsBlobStore.Builder builder)
Helper function to determine if any of the HttpClient configuration options have been set-
Methods inherited from class com.salesforce.multicloudj.blob.driver.AbstractBlobStore
abortMultipartUpload, completeMultipartUpload, copy, delete, delete, doesObjectExist, download, download, download, download, generatePresignedUrl, getMetadata, getTags, initiateMultipartUpload, list, listMultipartUpload, setTags, upload, upload, upload, upload, uploadMultipartPart
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.salesforce.multicloudj.blob.driver.BlobStore
getBucket, getRegion
-
Methods inherited from interface com.salesforce.multicloudj.common.provider.Provider
getProviderId
-
Methods inherited from interface com.salesforce.multicloudj.common.service.SdkService
getProviderId
-
-
-
-
Constructor Detail
-
AwsBlobStore
public AwsBlobStore()
-
AwsBlobStore
public AwsBlobStore(AwsBlobStore.Builder builder, software.amazon.awssdk.services.s3.S3Client s3Client)
-
-
Method Detail
-
shouldConfigureHttpClient
protected static boolean shouldConfigureHttpClient(AwsBlobStore.Builder builder)
Helper function to determine if any of the HttpClient configuration options have been set
-
builder
public AwsBlobStore.Builder builder()
Description copied from interface:Provider
Creates and returns a new Builder instance for this provider.- Returns:
- A Builder instance for constructing this provider.
-
getException
public Class<? extends SubstrateSdkException> getException(Throwable t)
Description copied from interface:SdkService
Maps a given Throwable from the provider implementation to a specific SubstrateSdkException. This is used for exception handling abstraction.- Parameters:
t
- The Throwable to be mapped.- Returns:
- The Class of the corresponding SubstrateSdkException.
-
doUpload
protected UploadResponse doUpload(UploadRequest uploadRequest, InputStream inputStream)
Performs Blob upload Note: Specifying the contentLength in the UploadRequest can dramatically improve upload efficiency because the substrate SDKs do not need to buffer the contents and calculate it themselves.- Specified by:
doUpload
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
uploadRequest
- Wrapper object containing upload datainputStream
- The input stream that contains the blob content- Returns:
- Wrapper object containing the upload result data
-
doUpload
protected UploadResponse doUpload(UploadRequest uploadRequest, byte[] content)
Performs Blob upload- Specified by:
doUpload
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
uploadRequest
- Wrapper object containing upload datacontent
- The byte array that contains the blob content- Returns:
- Wrapper object containing the upload result data
-
doUpload
protected UploadResponse doUpload(UploadRequest uploadRequest, File file)
Performs Blob upload- Specified by:
doUpload
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
uploadRequest
- Wrapper object containing upload datafile
- The File that contains the blob content- Returns:
- Wrapper object containing the upload result data
-
doUpload
protected UploadResponse doUpload(UploadRequest uploadRequest, Path path)
Performs Blob upload- Specified by:
doUpload
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
uploadRequest
- Wrapper object containing upload datapath
- The Path that contains the blob content- Returns:
- Wrapper object containing the upload result data
-
doUpload
protected UploadResponse doUpload(UploadRequest uploadRequest, software.amazon.awssdk.core.sync.RequestBody requestBody)
Helper function to upload blobs
-
doDownload
protected DownloadResponse doDownload(DownloadRequest downloadRequest, OutputStream outputStream)
Performs Blob download- Specified by:
doDownload
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
downloadRequest
- Wrapper object containing download dataoutputStream
- The output stream that the blob content will be written to- Returns:
- Returns a DownloadResponse object that contains metadata about the blob
-
doDownload
protected DownloadResponse doDownload(DownloadRequest downloadRequest, ByteArray byteArray)
Performs Blob download- Specified by:
doDownload
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
downloadRequest
- Wrapper object containing download databyteArray
- The byte array that blob content will be written to- Returns:
- Returns a DownloadResponse object that contains metadata about the blob
-
doDownload
protected DownloadResponse doDownload(DownloadRequest downloadRequest, File file)
Performs Blob download- Specified by:
doDownload
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
downloadRequest
- Wrapper object containing download datafile
- The File the blob content will be written to- Returns:
- Returns a DownloadResponse object that contains metadata about the blob
-
doDownload
protected DownloadResponse doDownload(DownloadRequest downloadRequest, Path path)
Performs Blob download- Specified by:
doDownload
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
downloadRequest
- Wrapper object containing download datapath
- The Path that blob content will be written to- Returns:
- Returns a DownloadResponse object that contains metadata about the blob
-
doDelete
protected void doDelete(String key, String versionId)
Deletes a single Blob- Specified by:
doDelete
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
key
- The key of the Blob to be deletedversionId
- The versionId of the blob
-
doDelete
protected void doDelete(Collection<BlobIdentifier> objects)
Deletes a collection of Blobs- Specified by:
doDelete
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
objects
- A collection of blob identifiers to delete
-
doCopy
protected CopyResponse doCopy(CopyRequest request)
Copies a Blob to a different bucket- Specified by:
doCopy
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
request
- the copy request- Returns:
- CopyResponse of the copied Blob
-
doGetMetadata
protected BlobMetadata doGetMetadata(String key, String versionId)
Retrieves the Blob metadata- Specified by:
doGetMetadata
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
key
- Key of the Blob whose metadata is to be retrievedversionId
- The versionId of the blob. This field is optional and only used if your bucket has versioning enabled. This value should be null unless you're targeting a specific key/version blob.- Returns:
- Wrapper Blob metadata object
-
doList
protected Iterator<BlobInfo> doList(ListBlobsRequest request)
Lists all objects in the bucket- Specified by:
doList
in classAbstractBlobStore<AwsBlobStore>
- Returns:
- Iterator of the list
-
doInitiateMultipartUpload
protected MultipartUpload doInitiateMultipartUpload(MultipartUploadRequest request)
Initiates a multipart upload- Specified by:
doInitiateMultipartUpload
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
request
- the multipart request- Returns:
- An object that acts as an identifier for subsequent related multipart operations
-
doUploadMultipartPart
protected UploadPartResponse doUploadMultipartPart(MultipartUpload mpu, MultipartPart mpp)
Uploads a part of the multipartUpload operation- Specified by:
doUploadMultipartPart
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
mpu
- The multipartUpload identifiermpp
- The part to be uploaded- Returns:
- Returns an identifier of the uploaded part
-
doCompleteMultipartUpload
protected MultipartUploadResponse doCompleteMultipartUpload(MultipartUpload mpu, List<UploadPartResponse> parts)
Completes a multipartUpload operation- Specified by:
doCompleteMultipartUpload
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
mpu
- The multipartUpload identifierparts
- The list of all parts that were uploaded- Returns:
- Returns a MultipartUploadResponse that contains an etag of the resultant blob
-
doListMultipartUpload
protected List<UploadPartResponse> doListMultipartUpload(MultipartUpload mpu)
List all parts that have been uploaded for the multipartUpload so far- Specified by:
doListMultipartUpload
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
mpu
- The multipartUpload identifier- Returns:
- Returns a list of all uploaded parts
-
doAbortMultipartUpload
protected void doAbortMultipartUpload(MultipartUpload mpu)
Aborts a multipartUpload that's in progress- Specified by:
doAbortMultipartUpload
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
mpu
- The multipartUpload identifier
-
doGetTags
protected Map<String,String> doGetTags(String key)
Returns a map of all the tags associated with the blob- Specified by:
doGetTags
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
key
- Name of the blob whose tags are to be retrieved- Returns:
- The blob's tags
-
doSetTags
protected void doSetTags(String key, Map<String,String> tags)
Sets tags on a blob- Specified by:
doSetTags
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
key
- Name of the blob to set tags ontags
- The tags to set
-
doGeneratePresignedUrl
protected URL doGeneratePresignedUrl(PresignedUrlRequest request)
Generates a presigned URL for uploading/downloading blobs- Specified by:
doGeneratePresignedUrl
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
request
- The PresignedUrlRequest- Returns:
- Returns the presigned URL
-
getPresigner
protected software.amazon.awssdk.services.s3.presigner.S3Presigner getPresigner()
Returns an S3Presigner for the current credentials- Returns:
- Returns an S3Presigner for the current credentials
-
doDoesObjectExist
protected boolean doDoesObjectExist(String key, String versionId)
Determines if an object exists for a given key/versionId- Specified by:
doDoesObjectExist
in classAbstractBlobStore<AwsBlobStore>
- Parameters:
key
- Name of the blob to checkversionId
- The version of the blob to check- Returns:
- Returns true if the object exists. Returns false if it doesn't exist.
-
-