Interface BlobWriteSession (2.40.1)

public interface BlobWriteSession

A session to write an object to Google Cloud Storage.

A session can only write a single version of an object. If writing multiple versions of an object a new session must be created each time.

Provides an api that allows writing to and retrieving the resulting BlobInfo after write finalization.

The underlying implementation is dictated based upon the specified BlobWriteSessionConfig provided at StorageOptions creation time. See Also: BlobWriteSessionConfigs, GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig), BlobWriteSessionConfig

Methods

getResult()

public abstract ApiFuture<BlobInfo> getResult()

Return an ApiFuture<BlobInfo> which will represent the state of the object upon finalization and success response from Google Cloud Storage.

This future will not resolve until: 1. The object is successfully finalized and created in Google Cloud Storage 2. A terminal failure occurs, the terminal failure will become the exception result

If a terminal failure is encountered, calling either ApiFuture#get() or ApiFuture#get(long, TimeUnit) will result in an java.util.concurrent.ExecutionException with a cause that is the StorageException.

Returns
Type Description
ApiFuture<BlobInfo>

open()

public abstract WritableByteChannel open()

Open the WritableByteChannel for this session.

A session may only be opened once. If multiple calls to open are made, an illegal state exception will be thrown

Upon calling WritableByteChannel#close() the object creation will be finalized, and #getResult()s future should resolve.

The returned WritableByteChannel can throw IOExceptions from any of its usual methods. Any IOException thrown can have a cause of a StorageException. However, not all IOExceptions will have StorageExceptions.

Returns
Type Description
WritableByteChannel
Exceptions
Type Description
IOException

When creating the WritableByteChannel if an unrecoverable underlying IOException occurs it can be rethrown