Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/storage/examples/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,14 @@ async fn run_object_appendable_examples(
.send()
.await?;

tracing::info!("running open_appendable_object_send_and_append example");
objects::open_appendable_object_send_and_append::sample(
client,
&rapid_bucket_id,
"appendable-send-and-append",
)
.await?;

tracing::info!("running open_appendable_object_write example");
objects::open_appendable_object_write::sample(client, &rapid_bucket_id, "appendable-write")
.await?;
Expand Down
2 changes: 2 additions & 0 deletions src/storage/examples/src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ pub mod open_appendable_object_pause_resume;
#[cfg(google_cloud_unstable_storage_bidi)]
pub mod open_appendable_object_read_tail;
#[cfg(google_cloud_unstable_storage_bidi)]
pub mod open_appendable_object_send_and_append;
#[cfg(google_cloud_unstable_storage_bidi)]
pub mod open_appendable_object_write;
pub mod open_multiple_objects_ranged_read;
pub mod open_object_multiple_ranged_read;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// [START storage_open_appendable_object_send_and_append]
use bytes::Bytes;
use google_cloud_storage::client::Storage;

pub async fn sample(client: &Storage, bucket: &str, object: &str) -> Result<(), anyhow::Error> {
let writer = client
.open_appendable_object(format!("projects/_/buckets/{bucket}"), object)
.send_and_append(Bytes::from("Hello World!"))
.await?;

let metadata = writer.finalize().await?;

println!("Created and appended data to {object} in bucket {bucket}: {metadata:?}");
Ok(())
}
// [END storage_open_appendable_object_send_and_append]
Loading