Class S3BlobStore

java.lang.Object
org.mockserver.blob.s3.S3BlobStore
All Implemented Interfaces:
AutoCloseable, BlobStore

public class S3BlobStore extends Object implements BlobStore
BlobStore implementation backed by AWS S3 (or any S3-compatible store such as MinIO). Blob keys are mapped to S3 object keys with an optional configurable prefix.

Metadata is stored as S3 user metadata on the object itself (the x-amz-meta-* headers). This avoids a secondary metadata store and keeps each blob's metadata atomically consistent with its data.

Thread-safety: S3Client is thread-safe; this class adds no mutable state beyond the injected client and configuration.

  • Constructor Details

    • S3BlobStore

      public S3BlobStore(software.amazon.awssdk.services.s3.S3Client s3Client, String bucket, String keyPrefix)
      Creates an S3 blob store.
      Parameters:
      s3Client - the AWS S3 client
      bucket - the S3 bucket name
      keyPrefix - optional key prefix (e.g. "mockserver/"); empty string for no prefix
  • Method Details

    • put

      public void put(String key, byte[] data, Map<String,String> metadata)
      Description copied from interface: BlobStore
      Stores a blob, overwriting any existing blob with the same key.
      Specified by:
      put in interface BlobStore
      Parameters:
      key - the blob key (e.g. a path-like string)
      data - the binary data
      metadata - optional metadata (may be empty, must not be null)
    • get

      public Optional<Blob> get(String key)
      Description copied from interface: BlobStore
      Retrieves a blob by key.
      Specified by:
      get in interface BlobStore
      Parameters:
      key - the blob key
      Returns:
      the blob, or empty if not present
    • list

      public List<String> list(String prefix)
      Description copied from interface: BlobStore
      Lists all blob keys that start with the given prefix.
      Specified by:
      list in interface BlobStore
      Parameters:
      prefix - the key prefix (e.g. "expectations/")
      Returns:
      list of matching keys
    • delete

      public boolean delete(String key)
      Description copied from interface: BlobStore
      Deletes a blob by key.
      Specified by:
      delete in interface BlobStore
      Parameters:
      key - the blob key
      Returns:
      true if the key was present
    • close

      public void close()
      Closes the underlying S3Client, releasing its HTTP connection pool and I/O threads.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface BlobStore