Class AwsBlobStore

java.lang.Object
com.salesforce.multicloudj.blob.driver.AbstractBlobStore
com.salesforce.multicloudj.blob.aws.AwsBlobStore
All Implemented Interfaces:
BlobStore, Provider, SdkService, AutoCloseable

@AutoService(AbstractBlobStore.class) public class AwsBlobStore extends AbstractBlobStore
AWS implementation of BlobStore
  • Constructor Details

    • AwsBlobStore

      public AwsBlobStore()
    • AwsBlobStore

      public AwsBlobStore(AwsBlobStore.Builder builder, software.amazon.awssdk.services.s3.S3Client s3Client)
  • Method Details

    • 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 class AbstractBlobStore
      Parameters:
      uploadRequest - Wrapper object containing upload data
      inputStream - 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 class AbstractBlobStore
      Parameters:
      uploadRequest - Wrapper object containing upload data
      content - 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 class AbstractBlobStore
      Parameters:
      uploadRequest - Wrapper object containing upload data
      file - 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 class AbstractBlobStore
      Parameters:
      uploadRequest - Wrapper object containing upload data
      path - 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 class AbstractBlobStore
      Parameters:
      downloadRequest - Wrapper object containing download data
      outputStream - 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 class AbstractBlobStore
      Parameters:
      downloadRequest - Wrapper object containing download data
      byteArray - 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 class AbstractBlobStore
      Parameters:
      downloadRequest - Wrapper object containing download data
      file - 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 class AbstractBlobStore
      Parameters:
      downloadRequest - Wrapper object containing download data
      path - The Path that blob content will be written to
      Returns:
      Returns a DownloadResponse object that contains metadata about the blob
    • doDownload

      protected DownloadResponse doDownload(DownloadRequest downloadRequest)
      Performs Blob download and returns an InputStream
      Specified by:
      doDownload in class AbstractBlobStore
      Parameters:
      downloadRequest - Wrapper object containing download data
      Returns:
      Returns a DownloadResponse object that contains metadata about the blob and an InputStream for reading the content
    • doDelete

      protected void doDelete(String key, String versionId)
      Deletes a single Blob
      Specified by:
      doDelete in class AbstractBlobStore
      Parameters:
      key - The key of the Blob to be deleted
      versionId - The versionId of the blob
    • doDelete

      protected void doDelete(Collection<BlobIdentifier> objects)
      Deletes a collection of Blobs
      Specified by:
      doDelete in class AbstractBlobStore
      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 class AbstractBlobStore
      Parameters:
      request - the copy request
      Returns:
      CopyResponse of the copied Blob
    • doCopyFrom

      protected CopyResponse doCopyFrom(CopyFromRequest request)
      Copies a Blob from a source bucket to the current bucket
      Specified by:
      doCopyFrom in class AbstractBlobStore
      Parameters:
      request - the copyFrom request
      Returns:
      CopyResponse of the copied Blob
    • doGetMetadata

      protected BlobMetadata doGetMetadata(String key, String versionId)
      Retrieves the Blob metadata
      Specified by:
      doGetMetadata in class AbstractBlobStore
      Parameters:
      key - Key of the Blob whose metadata is to be retrieved
      versionId - 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 class AbstractBlobStore
      Returns:
      Iterator of the list
    • doListPage

      protected ListBlobsPageResponse doListPage(ListBlobsPageRequest request)
      Lists a single page of objects in the bucket with pagination support
      Specified by:
      doListPage in class AbstractBlobStore
      Parameters:
      request - The list request containing filters and optional pagination token
      Returns:
      ListBlobsPageResponse containing the blobs, truncation status, and next page token
    • doInitiateMultipartUpload

      protected MultipartUpload doInitiateMultipartUpload(MultipartUploadRequest request)
      Initiates a multipart upload
      Specified by:
      doInitiateMultipartUpload in class AbstractBlobStore
      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 class AbstractBlobStore
      Parameters:
      mpu - The multipartUpload identifier
      mpp - 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 class AbstractBlobStore
      Parameters:
      mpu - The multipartUpload identifier
      parts - 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 class AbstractBlobStore
      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 class AbstractBlobStore
      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 class AbstractBlobStore
      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 class AbstractBlobStore
      Parameters:
      key - Name of the blob to set tags on
      tags - The tags to set
    • doGeneratePresignedUrl

      protected URL doGeneratePresignedUrl(PresignedUrlRequest request)
      Generates a presigned URL for uploading/downloading blobs
      Specified by:
      doGeneratePresignedUrl in class AbstractBlobStore
      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 class AbstractBlobStore
      Parameters:
      key - Name of the blob to check
      versionId - The version of the blob to check
      Returns:
      Returns true if the object exists. Returns false if it doesn't exist.
    • doDoesBucketExist

      protected boolean doDoesBucketExist()
      Specified by:
      doDoesBucketExist in class AbstractBlobStore
    • getObjectLock

      public ObjectLockInfo getObjectLock(String key, String versionId)
      Gets object lock configuration for a blob.
      Parameters:
      key - Object key
      versionId - Optional version ID. For versioned buckets, null means latest version.
      Returns:
      ObjectLockInfo containing lock configuration, or null if object lock is not configured
    • updateObjectRetention

      public void updateObjectRetention(String key, String versionId, Instant retainUntilDate)
      Updates object retention date. Only works if object is in GOVERNANCE mode. COMPLIANCE mode objects cannot be updated.
      Parameters:
      key - Object key
      versionId - Optional version ID. For versioned buckets, null means latest version.
      retainUntilDate - New retention expiration date
    • updateLegalHold

      public void updateLegalHold(String key, String versionId, boolean legalHold)
      Updates legal hold status on an object.
      Parameters:
      key - Object key
      versionId - Optional version ID. For versioned buckets, null means latest version.
      legalHold - true to apply hold, false to release hold
    • close

      public void close()
      Closes the underlying S3 client and releases any resources.