Add automatic content hash for uploads#385
Merged
Merged
Conversation
Compute and send a Dropbox content_hash for seekable upload streams so the server verifies upload integrity and rejects corrupted uploads. Applies to all upload routes whose request carries a ContentHash (direct upload and upload sessions). - ContentHasher: public helper computing the Dropbox block-SHA256 content hash (sync + async), plus WithoutAutoContentHash to opt a stream out. - Handler: hash the body before sending, restore the stream position, and set the hash on a cloned request; retry now rewinds to the original upload position rather than 0. - Property access is resolved once per request type and cached. - Config: DropboxClientConfig.AutoContentHash, on by default; opt out per-client or per-upload. Non-seekable streams and manually supplied hashes are left untouched. - Tests: unit tests for the hasher and upload wiring, and live e2e tests covering direct upload round-trip and a chunked upload session. - README: document the behavior, the 2x read cost, and opt-out.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #385 +/- ##
==========================================
+ Coverage 59.38% 61.60% +2.22%
==========================================
Files 16 17 +1
Lines 1433 1654 +221
Branches 136 155 +19
==========================================
+ Hits 851 1019 +168
- Misses 520 565 +45
- Partials 62 70 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rhui-dbx
approved these changes
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Computes and sends a Dropbox content_hash for seekable upload streams so the server verifies upload integrity and rejects corrupted uploads. Applies to all upload routes whose request carries a ContentHash (direct upload and upload sessions).
Behavior
Implementation
Tests