Skip to content

Comments

docs(storage): add sample for storage_open_object_multiple_ranged_read#4785

Open
vsharonlynn wants to merge 4 commits intogoogleapis:mainfrom
vsharonlynn:docs/storage_open_object_multiple_ranged_read
Open

docs(storage): add sample for storage_open_object_multiple_ranged_read#4785
vsharonlynn wants to merge 4 commits intogoogleapis:mainfrom
vsharonlynn:docs/storage_open_object_multiple_ranged_read

Conversation

@vsharonlynn
Copy link
Contributor

Add one of the samples requested in #4595.

@product-auto-label product-auto-label bot added api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels Feb 24, 2026
@vsharonlynn vsharonlynn force-pushed the docs/storage_open_object_multiple_ranged_read branch from 2fd53b5 to 80baabc Compare February 24, 2026 02:53
Copy link
Contributor

@joshuatants joshuatants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM

@vsharonlynn vsharonlynn force-pushed the docs/storage_open_object_multiple_ranged_read branch 2 times, most recently from 7177922 to 1e0aa29 Compare February 24, 2026 03:25
@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.01%. Comparing base (d2be5fd) to head (bbff7a3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4785   +/-   ##
=======================================
  Coverage   95.01%   95.01%           
=======================================
  Files         204      204           
  Lines        7877     7877           
=======================================
  Hits         7484     7484           
  Misses        393      393           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vsharonlynn vsharonlynn marked this pull request as ready for review February 24, 2026 05:08
@vsharonlynn vsharonlynn requested a review from a team as a code owner February 24, 2026 05:08
@joshuatants joshuatants self-requested a review February 24, 2026 05:40
Copy link
Contributor

@joshuatants joshuatants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Waiting for @coryan for final approval.

@vsharonlynn vsharonlynn requested a review from coryan February 24, 2026 05:48
Copy link
Collaborator

@coryan coryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a reason why downloading 5 and 2 bytes to a file is the best approach (e.g. because that is what the examples in other languages do) then please merge as-is.

But otherwise, it seems overly complicated to create files when a simple buffer would do.

Comment on lines 36 to 40
let mut file = File::create(&file_path).await?;
while let Some(data) = reader.next().await.transpose()? {
file.write_all(&data).await?;
}
file.sync_all().await?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why download to a file? That seems more complicated than downloading to a buffer (specially for 5 bytes!) and distracts from the main topic of the example.

Copy link
Contributor Author

@vsharonlynn vsharonlynn Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your inputs! I agree with your concerns.

Here are my changes to simplify the logic to focus on the main topic of the example:

  • Write to file --> Download to a buffer and printing
  • Downloading 5 and 2 bytes --> Download 5 bytes for both ranges
  • Clarified print statements to say "Read first range[...]" and "Read second range[...]" and print the content.

Please let me know if this version is clearer.

@vsharonlynn vsharonlynn force-pushed the docs/storage_open_object_multiple_ranged_read branch from a4aab4a to a7cfc59 Compare February 25, 2026 03:03
@vsharonlynn vsharonlynn force-pushed the docs/storage_open_object_multiple_ranged_read branch from a7cfc59 to bbff7a3 Compare February 25, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants