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: HttpStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig), BlobWriteSessionConfigs, GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig), BlobWriteSessionConfig
Methods
getResult()
publicabstractApiFuture<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
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-16 UTC."],[],[],null,["# Interface BlobWriteSession (2.55.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.55.0 (latest)](/java/docs/reference/google-cloud-storage/latest/com.google.cloud.storage.BlobWriteSession)\n- [2.54.0](/java/docs/reference/google-cloud-storage/2.54.0/com.google.cloud.storage.BlobWriteSession)\n- [2.53.3](/java/docs/reference/google-cloud-storage/2.53.3/com.google.cloud.storage.BlobWriteSession)\n- [2.52.3](/java/docs/reference/google-cloud-storage/2.52.3/com.google.cloud.storage.BlobWriteSession)\n- [2.50.0](/java/docs/reference/google-cloud-storage/2.50.0/com.google.cloud.storage.BlobWriteSession)\n- [2.49.0](/java/docs/reference/google-cloud-storage/2.49.0/com.google.cloud.storage.BlobWriteSession)\n- [2.48.2](/java/docs/reference/google-cloud-storage/2.48.2/com.google.cloud.storage.BlobWriteSession)\n- [2.47.0](/java/docs/reference/google-cloud-storage/2.47.0/com.google.cloud.storage.BlobWriteSession)\n- [2.46.0](/java/docs/reference/google-cloud-storage/2.46.0/com.google.cloud.storage.BlobWriteSession)\n- [2.45.0](/java/docs/reference/google-cloud-storage/2.45.0/com.google.cloud.storage.BlobWriteSession)\n- [2.44.1](/java/docs/reference/google-cloud-storage/2.44.1/com.google.cloud.storage.BlobWriteSession)\n- [2.43.2](/java/docs/reference/google-cloud-storage/2.43.2/com.google.cloud.storage.BlobWriteSession)\n- [2.42.0](/java/docs/reference/google-cloud-storage/2.42.0/com.google.cloud.storage.BlobWriteSession)\n- [2.41.0](/java/docs/reference/google-cloud-storage/2.41.0/com.google.cloud.storage.BlobWriteSession)\n- [2.40.1](/java/docs/reference/google-cloud-storage/2.40.1/com.google.cloud.storage.BlobWriteSession)\n- [2.39.0](/java/docs/reference/google-cloud-storage/2.39.0/com.google.cloud.storage.BlobWriteSession)\n- [2.38.0](/java/docs/reference/google-cloud-storage/2.38.0/com.google.cloud.storage.BlobWriteSession)\n- [2.37.0](/java/docs/reference/google-cloud-storage/2.37.0/com.google.cloud.storage.BlobWriteSession)\n- [2.36.1](/java/docs/reference/google-cloud-storage/2.36.1/com.google.cloud.storage.BlobWriteSession)\n- [2.34.0](/java/docs/reference/google-cloud-storage/2.34.0/com.google.cloud.storage.BlobWriteSession)\n- [2.33.0](/java/docs/reference/google-cloud-storage/2.33.0/com.google.cloud.storage.BlobWriteSession)\n- [2.32.1](/java/docs/reference/google-cloud-storage/2.32.1/com.google.cloud.storage.BlobWriteSession)\n- [2.30.1](/java/docs/reference/google-cloud-storage/2.30.1/com.google.cloud.storage.BlobWriteSession)\n- [2.29.1](/java/docs/reference/google-cloud-storage/2.29.1/com.google.cloud.storage.BlobWriteSession)\n- [2.28.0](/java/docs/reference/google-cloud-storage/2.28.0/com.google.cloud.storage.BlobWriteSession)\n- [2.27.1](/java/docs/reference/google-cloud-storage/2.27.1/com.google.cloud.storage.BlobWriteSession)\n- [2.24.0](/java/docs/reference/google-cloud-storage/2.24.0/com.google.cloud.storage.BlobWriteSession)\n- [2.23.0](/java/docs/reference/google-cloud-storage/2.23.0/com.google.cloud.storage.BlobWriteSession)\n- [2.22.6](/java/docs/reference/google-cloud-storage/2.22.6/com.google.cloud.storage.BlobWriteSession)\n- [2.21.0](/java/docs/reference/google-cloud-storage/2.21.0/com.google.cloud.storage.BlobWriteSession)\n- [2.20.2](/java/docs/reference/google-cloud-storage/2.20.2/com.google.cloud.storage.BlobWriteSession)\n- [2.19.0](/java/docs/reference/google-cloud-storage/2.19.0/com.google.cloud.storage.BlobWriteSession)\n- [2.18.0](/java/docs/reference/google-cloud-storage/2.18.0/com.google.cloud.storage.BlobWriteSession)\n- [2.17.2](/java/docs/reference/google-cloud-storage/2.17.2/com.google.cloud.storage.BlobWriteSession)\n- [2.16.0](/java/docs/reference/google-cloud-storage/2.16.0/com.google.cloud.storage.BlobWriteSession)\n- [2.15.1](/java/docs/reference/google-cloud-storage/2.15.1/com.google.cloud.storage.BlobWriteSession)\n- [2.14.0](/java/docs/reference/google-cloud-storage/2.14.0/com.google.cloud.storage.BlobWriteSession)\n- [2.13.1](/java/docs/reference/google-cloud-storage/2.13.1/com.google.cloud.storage.BlobWriteSession)\n- [2.12.0](/java/docs/reference/google-cloud-storage/2.12.0/com.google.cloud.storage.BlobWriteSession)\n- [2.11.3](/java/docs/reference/google-cloud-storage/2.11.3/com.google.cloud.storage.BlobWriteSession)\n- [2.10.0](/java/docs/reference/google-cloud-storage/2.10.0/com.google.cloud.storage.BlobWriteSession)\n- [2.9.3](/java/docs/reference/google-cloud-storage/2.9.3/com.google.cloud.storage.BlobWriteSession)\n- [2.8.1](/java/docs/reference/google-cloud-storage/2.8.1/com.google.cloud.storage.BlobWriteSession)\n- [2.7.1](/java/docs/reference/google-cloud-storage/2.7.1/com.google.cloud.storage.BlobWriteSession)\n- [2.6.1](/java/docs/reference/google-cloud-storage/2.6.1/com.google.cloud.storage.BlobWriteSession)\n- [2.5.1](/java/docs/reference/google-cloud-storage/2.5.1/com.google.cloud.storage.BlobWriteSession)\n- [2.4.5](/java/docs/reference/google-cloud-storage/2.4.5/com.google.cloud.storage.BlobWriteSession)\n- [2.3.0](/java/docs/reference/google-cloud-storage/2.3.0/com.google.cloud.storage.BlobWriteSession)\n- [2.2.3](/java/docs/reference/google-cloud-storage/2.2.3/com.google.cloud.storage.BlobWriteSession)\n- [2.1.10](/java/docs/reference/google-cloud-storage/2.1.10/com.google.cloud.storage.BlobWriteSession) \n| **Beta**\n|\n|\n| This library is covered by the [Pre-GA Offerings Terms](/terms/service-terms#1)\n| of the Terms of Service. Pre-GA libraries might have limited support,\n| and changes to pre-GA libraries might not be compatible with other pre-GA versions.\n| For more information, see the\n[launch stage descriptions](/products#product-launch-stages). \n\n public interface BlobWriteSession\n\nA session to write an object to Google Cloud Storage.\n\nA session can only write a single version of an object. If writing multiple versions of an\nobject a new session must be created each time.\n\nProvides an api that allows writing to and retrieving the resulting [BlobInfo](/java/docs/reference/google-cloud-storage/latest/com.google.cloud.storage.BlobInfo) after\nwrite finalization.\n\nThe underlying implementation is dictated based upon the specified [BlobWriteSessionConfig](/java/docs/reference/google-cloud-storage/latest/com.google.cloud.storage.BlobWriteSessionConfig) provided at [StorageOptions](/java/docs/reference/google-cloud-storage/latest/com.google.cloud.storage.StorageOptions) creation time.\nSee Also: HttpStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig), [BlobWriteSessionConfigs](/java/docs/reference/google-cloud-storage/latest/com.google.cloud.storage.BlobWriteSessionConfigs), GrpcStorageOptions.Builder#setBlobWriteSessionConfig(BlobWriteSessionConfig), [BlobWriteSessionConfig](/java/docs/reference/google-cloud-storage/latest/com.google.cloud.storage.BlobWriteSessionConfig)\n\nMethods\n-------\n\n### getResult()\n\n public abstract ApiFuture\u003cBlobInfo\u003e getResult()\n\n| **Beta**\n|\n| This feature is covered by the [Pre-GA Offerings Terms](/terms/service-terms#1) of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.\n\nReturn an [ApiFuture](https://cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.ApiFuture.html)`\u003cBlobInfo\u003e` which will represent the state of the object upon\nfinalization and success response from Google Cloud Storage.\n\nThis future will not resolve until: 1. The object is successfully finalized and created in\nGoogle Cloud Storage 2. A terminal failure occurs, the terminal failure will become the\nexception result\n\nIf a terminal failure is encountered, calling either ApiFuture#get() or ApiFuture#get(long, TimeUnit) will result in an [java.util.concurrent.ExecutionException](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutionException.html) with a cause that is the [StorageException](/java/docs/reference/google-cloud-storage/latest/com.google.cloud.storage.StorageException).\n\n### open()\n\n public abstract WritableByteChannel open()\n\n| **Beta**\n|\n| This feature is covered by the [Pre-GA Offerings Terms](/terms/service-terms#1) of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.\n\nOpen the [WritableByteChannel](https://docs.oracle.com/javase/8/docs/api/java/nio/channels/WritableByteChannel.html) for this session.\n\nA session may only be `open`ed once. If multiple calls to open are made, an illegal\nstate exception will be thrown\n\nUpon calling WritableByteChannel#close() the object creation will be finalized, and\n[#getResult()](/java/docs/reference/google-cloud-storage/latest/com.google.cloud.storage.BlobWriteSession#com_google_cloud_storage_BlobWriteSession_getResult__)s future should resolve.\n\nThe returned `WritableByteChannel` can throw IOExceptions from any of its usual\nmethods. Any [IOException](https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html) thrown can have a cause of a [StorageException](/java/docs/reference/google-cloud-storage/latest/com.google.cloud.storage.StorageException).\nHowever, not all `IOExceptions` will have `StorageException`s."]]