Skip to content

feat(core,services/s3): support supplying a precomputed checksum on write#7830

Open
wolfv wants to merge 1 commit into
apache:mainfrom
wolfv:feat/write-with-checksum
Open

feat(core,services/s3): support supplying a precomputed checksum on write#7830
wolfv wants to merge 1 commit into
apache:mainfrom
wolfv:feat/write-with-checksum

Conversation

@wolfv

@wolfv wolfv commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #.

Rationale for this change

Users often already know an object's checksum ahead of time (for example a SHA-256 they computed when producing the data) and want the storage service to verify the upload against that value, rather than having OpenDAL recompute one from the body. There is currently no way to pass a known checksum through a write operation.

What changes are included in this PR?

A new, additive public API in opendal-core:

  • Checksum type and ChecksumAlgorithm enum (Checksum::sha256(bytes), crc32c, sha1, crc64nvme). The value holds the raw digest bytes; services encode it as their wire format requires.
  • WriteOptions::checksum field, OpWrite::with_checksum / OpWrite::checksum accessors, and a Operator::write_with(...).checksum(...) builder method (plus the same on writer_with).
  • Capability::write_with_checksum to advertise support.

S3 service support:

  • On the single-shot PutObject path, a supplied checksum is sent as the matching x-amz-checksum-* header (base64-encoded from the raw digest bytes) instead of computing one from the body.
  • A whole-object checksum cannot be mapped onto individual multipart parts, so S3 returns Unsupported when a checksum is combined with append or multipart writes, rather than silently dropping the integrity check.

Unit tests cover the header mapping, and doctests cover the new public API.

Are there any user-facing changes?

Yes, all additive (no breaking changes):

  • New public items: opendal::Checksum, opendal::ChecksumAlgorithm, WriteOptions::checksum, Operator::write_with(...).checksum(...), Capability::write_with_checksum.

AI Usage Statement

This PR was prepared with the assistance of Claude Code (Claude Opus 4.8). All changes were reviewed by the author.

…rite

Add a public `Checksum` type and `ChecksumAlgorithm` enum to opendal-core,
a `WriteOptions::checksum` field, an `OpWrite::with_checksum` accessor, and
a `write_with(...).checksum(...)` builder method. A new
`Capability::write_with_checksum` flag advertises support.

The S3 service consumes a supplied checksum on the single-shot PutObject
path, emitting the matching `x-amz-checksum-*` header from the raw digest
bytes instead of computing one from the body. Because a whole-object
checksum cannot be mapped onto individual parts, S3 returns Unsupported
when a checksum is combined with append or multipart writes rather than
silently dropping the integrity check.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wolfv wolfv requested a review from Xuanwo as a code owner June 29, 2026 16:48
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. releases-note/feat The PR implements a new feature or has a title that begins with "feat" labels Jun 29, 2026
@Xuanwo

Xuanwo commented Jun 30, 2026

Copy link
Copy Markdown
Member

Maybe it worths to take a look at #6817

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants