io.atlassian.blobstore.client.api
Interface BlobStoreService


public interface BlobStoreService

Service exposing get, put and delete methods for blobs. All parameters are not null, and NullPointerException will be thrown if nulls are supplied as parameters.


Method Summary
 com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Either<Failure,java.lang.Boolean>> delete(java.lang.String key)
          Deletes a blob.
<A> com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Either<Failure,A>>
get(java.lang.String key, Access options, com.google.common.base.Function<com.atlassian.fugue.Option<GetResult>,A> f)
          Gets a blob, and applies the function to it to produce a result.
 com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Either<Failure,com.atlassian.fugue.Option<HeadResult>>> head(java.lang.String key, Access options)
          Gets the header information of a blob.
 com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Either<Failure,PutResult>> put(java.lang.String key, java.io.InputStream stream, java.lang.Long contentLength)
          Stores the given input stream into a new blob and returns the the blob's PutResult.
 

Method Detail

get

<A> com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Either<Failure,A>> get(java.lang.String key,
                                                                                     Access options,
                                                                                     com.google.common.base.Function<com.atlassian.fugue.Option<GetResult>,A> f)
Gets a blob, and applies the function to it to produce a result.

Internally, the input stream will be closed, the function does not need to handle closing the stream.

Type Parameters:
A - return type of the callback function. This must not be Void. If you don't want to return anything from the function use Unit.
Parameters:
key - the blob's logical key
options - request options, like caching parameters
f - callback function. This function cannot return null. If you don't want to return anything from the function use Unit.
Returns:
A promise of either the result of the callback function or a Failure. Possible values are
  • Either.left(Failure): a non-recoverable error occurred and the callback function was not called.
  • Either.right(value): the callback was called on the blob with Some(InputStream) if a blob was found for logical key 'key', or None if not blob was found. value was returned by the callback.

put

com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Either<Failure,PutResult>> put(java.lang.String key,
                                                                                         java.io.InputStream stream,
                                                                                         java.lang.Long contentLength)
Stores the given input stream into a new blob and returns the the blob's PutResult.

Parameters:
key - the blob's logical key
stream - data to upload
contentLength - in bytes
Returns:
A promise of either the PutResult of the written blob or a Failure. Possible values are
  • Either.left(Failure): the blob was not stored
  • Either.right(PutResult): the blob was stored, the PutResult object can be used to get further information on the details of the operation

delete

com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Either<Failure,java.lang.Boolean>> delete(java.lang.String key)
Deletes a blob.

Parameters:
key - the blob's logical key
Returns:
A promise of either the result of the delete operation or a Failure. Possible values are
  • Either.left(Failure): the blob was not deleted
  • Either.right(false): the blob was not deleted because it was not found
  • Either.right(true): the blob was successfully deleted

head

com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Either<Failure,com.atlassian.fugue.Option<HeadResult>>> head(java.lang.String key,
                                                                                                                       Access options)
Gets the header information of a blob.

Parameters:
key - the blob's logical key
options - request options, like caching parameters
Returns:
A promise of the HeadResult of the the blob if it exists, None if it does not exist, or a Failure in the event of any non-recoverable errors. Possible values are
  • Either.left(errorMessage): non-recoverable error, could not determine whether blob exists or access its metadata.
  • Either.right(None): the Blobstore service was successfully contacted, but the blob with logical key 'key' does not exist
  • Either.right(Some(HeadResult)): a blob is stored at logical key 'key' and meta data is in HeadResult instance.