Interface ObjectStorage


@DoNotInherit public interface ObjectStorage
Client for a single named bucket. Obtained via ObjectStorageProvider.forBucket(String).

Not for user extension.

  • Method Details

    • bucketName

      String bucketName()
      Returns:
      The logical name of the bucket this store interacts with
    • get

      Retrieve an object, returning both its metadata and full content, or Optional.empty() if no object exists for the given key.

      Blocks the calling thread until the operation completes. Safe to call on a Loom virtual thread. For large objects prefer getStreamAsync(String).

    • put

      void put(String key, akka.util.ByteString data)
      Store an object without an explicit content type.

      Blocks the calling thread until the operation completes. Use getMetadata(String) to retrieve metadata after the write if needed.

      Parameters:
      key - object key within the bucket
      data - content to store
    • put

      void put(String key, akka.util.ByteString data, akka.http.javadsl.model.ContentType contentType)
      Store an object with an explicit content type.

      Blocks the calling thread until the operation completes. Use getMetadata(String) to retrieve metadata after the write if needed.

      Parameters:
      key - object key within the bucket
      data - content to store
      contentType - MIME type of the content
    • put

      void put(String key, akka.util.ByteString data, akka.http.javadsl.model.ContentType contentType, Map<String,String> metadata)
      Store an object with an explicit content type.

      Blocks the calling thread until the operation completes. Use getMetadata(String) to retrieve metadata after the write if needed.

      Parameters:
      key - object key within the bucket
      data - content to store
      contentType - MIME type of the content
      metadata - Additional metadata to store with the data
    • delete

      void delete(String key)
      Delete the object with the given key. Succeeds silently if the key does not exist.

      Blocks the calling thread until the operation completes.

    • listObjects

      List<ObjectMetadata> listObjects(String prefix)
      List all objects whose keys start with prefix. Pass an empty string to list all objects in the bucket.

      Be careful listing buckets with large numbers of entries, all will be collected into memory of the service.

    • listObjects

      List<ObjectMetadata> listObjects()
      List all objects in the bucket.

      Be careful listing buckets with large numbers of entries, all will be collected into memory of the service.

    • getMetadata

      Optional<ObjectMetadata> getMetadata(String key)
      Retrieve only the metadata for an object without downloading its content, or Optional.empty() if no object exists for the given key.

      Blocks the calling thread until the operation completes.

    • listObjectsStream

      akka.stream.javadsl.Source<ObjectMetadata,akka.NotUsed> listObjectsStream(String prefix)
      List all objects whose keys start with prefix. Pass an empty string to list all objects in the bucket.
    • listObjectsStream

      akka.stream.javadsl.Source<ObjectMetadata,akka.NotUsed> listObjectsStream()
      List all objects in the bucket.
    • getStreamAsync

      CompletionStage<Optional<akka.stream.javadsl.Source<akka.util.ByteString,akka.NotUsed>>> getStreamAsync(String key)
      Retrieve an object as a streaming source, or Optional.empty() if no object exists for the given key. Prefer this over get(String) for large objects that may not fit in JVM heap. Use getMetadataAsync(String) to retrieve metadata separately if needed.
    • putStreamAsync

      CompletionStage<akka.Done> putStreamAsync(String key, akka.stream.javadsl.Source<akka.util.ByteString,?> data)
      Store an object from a streaming source without an explicit content type. Use getMetadataAsync(String) to retrieve metadata after the write if needed.
      Parameters:
      key - object key within the bucket
      data - stream of content chunks
    • putStreamAsync

      CompletionStage<akka.Done> putStreamAsync(String key, akka.stream.javadsl.Source<akka.util.ByteString,?> data, akka.http.javadsl.model.ContentType contentType)
      Store an object from a streaming source with an explicit content type. Use getMetadataAsync(String) to retrieve metadata after the write if needed.
      Parameters:
      key - object key within the bucket
      data - stream of content chunks
      contentType - MIME type of the content
    • putStreamAsync

      CompletionStage<akka.Done> putStreamAsync(String key, akka.stream.javadsl.Source<akka.util.ByteString,?> data, akka.http.javadsl.model.ContentType contentType, Map<String,String> metadata)
      Store an object from a streaming source with an explicit content type. Use getMetadataAsync(String) to retrieve metadata after the write if needed.
      Parameters:
      key - object key within the bucket
      data - stream of content chunks
      contentType - MIME type of the content
      metadata - Additional metadata to store with the data
    • getAsync

      Async variant of get(String). Returns a CompletionStage that completes with the object, or an empty Optional if no object exists for the given key.
    • putAsync

      CompletionStage<akka.Done> putAsync(String key, akka.util.ByteString data)
      Async variant of put(String, ByteString). Returns a CompletionStage that completes when the object has been stored.
    • putAsync

      CompletionStage<akka.Done> putAsync(String key, akka.util.ByteString data, akka.http.javadsl.model.ContentType contentType)
      Async variant of put(String, ByteString, ContentType). Returns a CompletionStage that completes when the object has been stored.
    • putAsync

      CompletionStage<akka.Done> putAsync(String key, akka.util.ByteString data, akka.http.javadsl.model.ContentType contentType, Map<String,String> metadata)
      Async variant of put(String, ByteString, ContentType, Map). Returns a CompletionStage that completes when the object has been stored.
    • deleteAsync

      CompletionStage<akka.Done> deleteAsync(String key)
      Async variant of delete(String). Returns a CompletionStage that completes when the object has been deleted.
    • getMetadataAsync

      CompletionStage<Optional<ObjectMetadata>> getMetadataAsync(String key)
      Async variant of getMetadata(String). Returns a CompletionStage that completes with the metadata, or an empty Optional if no object exists for the given key.