Class GcsBlobStore

java.lang.Object
org.mockserver.blob.gcs.GcsBlobStore
All Implemented Interfaces:
AutoCloseable, BlobStore

public class GcsBlobStore extends Object implements BlobStore
BlobStore implementation backed by Google Cloud Storage. Blob keys are mapped to GCS object names with an optional configurable prefix.

Metadata is stored as GCS object metadata (custom key-value pairs on the object itself).

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

  • Constructor Details

    • GcsBlobStore

      public GcsBlobStore(com.google.cloud.storage.Storage storage, String bucket, String keyPrefix)
      Creates a GCS blob store.
      Parameters:
      storage - the GCS storage client (caller owns lifecycle)
      bucket - the GCS bucket name
      keyPrefix - optional key prefix; 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 GCS Storage client, releasing its HTTP transport resources. Storage implements AutoCloseable.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface BlobStore