docs(storage): add sample for storage_open_object_multiple_ranged_read#4785
docs(storage): add sample for storage_open_object_multiple_ranged_read#4785vsharonlynn wants to merge 4 commits intogoogleapis:mainfrom
Conversation
2fd53b5 to
80baabc
Compare
src/storage/examples/src/objects/open_object_multiple_ranged_read.rs
Outdated
Show resolved
Hide resolved
7177922 to
1e0aa29
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
joshuatants
left a comment
There was a problem hiding this comment.
LGTM. Waiting for @coryan for final approval.
coryan
left a comment
There was a problem hiding this comment.
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.
| 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?; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/storage/examples/src/objects/open_object_multiple_ranged_read.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Carlos O'Ryan <coryan@google.com>
a4aab4a to
a7cfc59
Compare
a7cfc59 to
bbff7a3
Compare
Add one of the samples requested in #4595.