You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "waynexia (via GitHub)" <gi...@apache.org> on 2025/08/15 01:09:15 UTC

[PR] feat: implement content-md5 for s3 [opendal]

waynexia opened a new pull request, #6508:
URL: https://github.com/apache/opendal/pull/6508

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Part of #5550.
   
   # Rationale for this change
   
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   `Content-MD5` is required in some S3-compatible services
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   Add `Content-MD5` support for S3 backend.
   
   Test with `oli`
   
   <img width="582" height="140" alt="image" src="https://github.com/user-attachments/assets/8204d036-dd6a-4ba4-8e40-5b17ad8a8a52" />
   
   
   # Are there any user-facing changes?
   
   
   New option for S3 backend
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking-changes` label.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: implement content-md5 for s3 [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #6508:
URL: https://github.com/apache/opendal/pull/6508#discussion_r2476522367


##########
core/src/services/s3/core.rs:
##########
@@ -275,6 +275,7 @@ impl S3Core {
                     .for_each(|b| crc = crc32c::crc32c_append(crc, &b));
                 Some(BASE64_STANDARD.encode(crc.to_be_bytes()))
             }
+            Some(ChecksumAlgorithm::Md5) => Some(format_content_md5(body.to_bytes().as_ref())),

Review Comment:
   Do we have a better way to handle this, like calculating in a stream instead of calling `body.to_bytes()` first? Our users might send data up to 5GiB in a single request.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: implement content-md5 for s3 [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #6508:
URL: https://github.com/apache/opendal/pull/6508#discussion_r2278179655


##########
core/src/services/s3/config.rs:
##########
@@ -196,6 +196,13 @@ pub struct S3Config {
 
     /// Indicates whether the client agrees to pay for the requests made to the S3 bucket.
     pub enable_request_payer: bool,
+
+    /// Enable Content-MD5 header for upload operations.
+    ///
+    /// When enabled, OpenDAL will calculate and include the Content-MD5 header
+    /// for PUT operations (single uploads, multipart parts, and append operations).
+    /// This header provides an additional layer of data integrity verification.
+    pub enable_content_md5: bool,

Review Comment:
   I don't think it's the correct approch to implement data integrity verification.
   
   Maybe we can take a look over https://github.com/apache/opendal/issues/5549



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: implement content-md5 for s3 [opendal]

Posted by "waynexia (via GitHub)" <gi...@apache.org>.
waynexia commented on code in PR #6508:
URL: https://github.com/apache/opendal/pull/6508#discussion_r2476797964


##########
core/src/services/s3/core.rs:
##########
@@ -275,6 +275,7 @@ impl S3Core {
                     .for_each(|b| crc = crc32c::crc32c_append(crc, &b));
                 Some(BASE64_STANDARD.encode(crc.to_be_bytes()))
             }
+            Some(ChecksumAlgorithm::Md5) => Some(format_content_md5(body.to_bytes().as_ref())),

Review Comment:
   :+1: made a non-copy version `format_content_md5_iter` that works on iterator



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: implement content-md5 for s3 [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #6508:
URL: https://github.com/apache/opendal/pull/6508#discussion_r2278182884


##########
core/src/services/s3/config.rs:
##########
@@ -196,6 +196,13 @@ pub struct S3Config {
 
     /// Indicates whether the client agrees to pay for the requests made to the S3 bucket.
     pub enable_request_payer: bool,
+
+    /// Enable Content-MD5 header for upload operations.
+    ///
+    /// When enabled, OpenDAL will calculate and include the Content-MD5 header
+    /// for PUT operations (single uploads, multipart parts, and append operations).
+    /// This header provides an additional layer of data integrity verification.
+    pub enable_content_md5: bool,

Review Comment:
   How about implementing `content_md5` as one of `checksum_algorithm`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: implement content-md5 for s3 [opendal]

Posted by "waynexia (via GitHub)" <gi...@apache.org>.
waynexia commented on code in PR #6508:
URL: https://github.com/apache/opendal/pull/6508#discussion_r2278186477


##########
core/src/services/s3/config.rs:
##########
@@ -196,6 +196,13 @@ pub struct S3Config {
 
     /// Indicates whether the client agrees to pay for the requests made to the S3 bucket.
     pub enable_request_payer: bool,
+
+    /// Enable Content-MD5 header for upload operations.
+    ///
+    /// When enabled, OpenDAL will calculate and include the Content-MD5 header
+    /// for PUT operations (single uploads, multipart parts, and append operations).
+    /// This header provides an additional layer of data integrity verification.
+    pub enable_content_md5: bool,

Review Comment:
   sounds good. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: implement content-md5 for s3 [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #6508:
URL: https://github.com/apache/opendal/pull/6508


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org