An interface to asynchronously perform resumable uploads.
The client library uses the google.storage.v2.StorageService.BidiWriteObject
RPC to perform asynchronous resumable uploads to Google Cloud Storage. As the name implies, this is a bi-directional RPC. The messages sent via this RPC are google.storage.v2.BidiWriteObjectRequest
and google.storage.v2.BidiWriteObjectResponse
.
- The
BidiWriteObjectRequest
messages upload the object data. - The last
BidiWriteObjectRequest
message in an upload must include afinalize
attribute. These messages result in aBidiWriteObjectResponse
message, which includes the metadata of the GCS object created by the upload. BidiWriteObjectRequest
messages may include aflush
attribute. Such messages result in aBidiReadObjectResponse
message, which includes how much of the uploaded data has been persisted.
This interface uses different member functions to write messages with and without the finalize
attribute. The functions have different return types reflecting the absence of response messages for BidiWriteObjectRequest
messages that do not finalize an upload.
This interface does not provide a member function to create BidiWriteObjectRequest
messages with a flush
attribute.
This interface can be used to mock the behavior of these bidirectional streaming RPCs. Applications may use these mocks in their own tests.
Functions
Cancel()
Cancels the streaming RPC, terminating any pending operations.
Returns | |
---|---|
Type | Description |
void |
UploadId() const
Returns the upload id. Used to checkpoint the state and resume uploads.
Returns | |
---|---|
Type | Description |
std::string |
PersistedState() const
Returns the last known state of the upload.
Updated during initialization and by a successful Finalize()
request.
Returns | |
---|---|
Type | Description |
absl::variant< std::int64_t, storage::ObjectMetadata > |
Write(WritePayload)
Uploads some data to the service.
Parameter | |
---|---|
Name | Description |
payload |
WritePayload
|
Returns | |
---|---|
Type | Description |
future< Status > |
Finalize(WritePayload)
Finalizes an upload.
Parameter | |
---|---|
Name | Description |
|
WritePayload
|
Returns | |
---|---|
Type | Description |
future< StatusOr< storage::ObjectMetadata > > |