Class MultipartStore

java.lang.Object
com.adobe.testing.s3mock.store.MultipartStore

public class MultipartStore extends Object
Stores parts and their metadata created in S3Mock.
  • Constructor Details

    • MultipartStore

      public MultipartStore(boolean retainFilesOnExit, ObjectStore objectStore)
  • Method Details

    • prepareMultipartUpload

      public MultipartUpload prepareMultipartUpload(BucketMetadata bucket, String key, UUID id, String contentType, Map<String,String> storeHeaders, String uploadId, Owner owner, Owner initiator, Map<String,String> userMetadata, Map<String,String> encryptionHeaders)
      Prepares everything to store an object uploaded as multipart upload.
      Parameters:
      bucket - Bucket to upload object in
      key - object to upload
      id - ID of the object
      contentType - the content type
      storeHeaders - various headers to store
      uploadId - id of the upload
      owner - owner of the upload
      initiator - initiator of the upload
      userMetadata - custom metadata
      Returns:
      upload result
    • listMultipartUploads

      public List<MultipartUpload> listMultipartUploads(String bucketName, String prefix)
      Lists all not-yet completed parts of multipart uploads in a bucket.
      Parameters:
      bucketName - the bucket to use as a filter
      prefix - the prefix use as a filter
      Returns:
      the list of not-yet completed multipart uploads.
    • getMultipartUpload

      public MultipartUpload getMultipartUpload(String uploadId)
      Get MultipartUpload, if it was not completed.
      Parameters:
      uploadId - id of the upload
      Returns:
      the multipart upload, if it exists, throws IllegalArgumentException otherwise.
    • abortMultipartUpload

      public void abortMultipartUpload(BucketMetadata bucket, UUID id, String uploadId)
      Aborts the upload.
      Parameters:
      bucket - to which was uploaded
      id - of the object
      uploadId - of the upload
    • putPart

      public String putPart(BucketMetadata bucket, UUID id, String uploadId, String partNumber, InputStream inputStream, boolean useV4ChunkedWithSigningFormat, Map<String,String> encryptionHeaders)
      Uploads a part of a multipart upload.
      Parameters:
      bucket - in which to upload
      id - of the object to upload
      uploadId - id of the upload
      partNumber - number of the part to store
      inputStream - file data to be stored
      useV4ChunkedWithSigningFormat - If true, V4-style signing is enabled.
      Returns:
      the md5 digest of this part
    • completeMultipartUpload

      public String completeMultipartUpload(BucketMetadata bucket, String key, UUID id, String uploadId, List<CompletedPart> parts, Map<String,String> encryptionHeaders)
      Completes a Multipart Upload for the given ID.
      Parameters:
      bucket - in which to upload.
      key - of the object to upload.
      id - id of the object
      uploadId - id of the upload.
      parts - to concatenate.
      Returns:
      etag of the uploaded file.
    • getMultipartUploadParts

      public List<Part> getMultipartUploadParts(BucketMetadata bucket, UUID id, String uploadId)
      Get all multipart upload parts.
      Parameters:
      bucket - name of the bucket
      id - object ID
      uploadId - upload identifier
      Returns:
      List of Parts
    • copyPart

      public String copyPart(BucketMetadata bucket, UUID id, org.springframework.http.HttpRange copyRange, String partNumber, BucketMetadata destinationBucket, UUID destinationId, String uploadId, Map<String,String> encryptionHeaders)
      Copies the range, define by from/to, from the S3 Object, identified by the given key to given destination into the given bucket.
      Parameters:
      bucket - The source Bucket.
      id - Identifies the S3 Object.
      copyRange - Byte range to copy. Optional.
      partNumber - The part to copy.
      destinationBucket - The Bucket the target object (will) reside in.
      destinationId - The target object ID.
      uploadId - id of the upload.
      Returns:
      etag of the uploaded file.