@@ -23,12 +23,12 @@ use crate::s3::response::{
2323 CopyObjectInternalResponse , CopyObjectResponse , CreateMultipartUploadResponse ,
2424 StatObjectResponse , UploadPartCopyResponse ,
2525} ;
26- use crate :: s3:: response_traits:: HasEtagFromBody ;
26+ use crate :: s3:: response_traits:: { HasChecksumHeaders , HasEtagFromBody } ;
2727use crate :: s3:: sse:: { Sse , SseCustomerKey } ;
2828use crate :: s3:: types:: { Directive , PartInfo , Retention , S3Api , S3Request , ToS3Request } ;
2929use crate :: s3:: utils:: {
30- UtcTime , check_bucket_name, check_object_name, check_sse, check_ssec, to_http_header_value ,
31- to_iso8601utc, url_encode,
30+ ChecksumAlgorithm , UtcTime , check_bucket_name, check_object_name, check_sse, check_ssec,
31+ to_http_header_value , to_iso8601utc, url_encode,
3232} ;
3333use async_recursion:: async_recursion;
3434use http:: Method ;
@@ -59,6 +59,13 @@ pub struct UploadPartCopy {
5959 part_number : u16 ,
6060 #[ builder( default ) ]
6161 headers : Multimap ,
62+ /// Optional checksum algorithm for data integrity verification during part copy.
63+ ///
64+ /// When specified, the server computes a checksum of the copied part data using
65+ /// this algorithm. Use the same algorithm for all parts in a multipart upload.
66+ /// Supported algorithms: CRC32, CRC32C, SHA1, SHA256, CRC64NVME.
67+ #[ builder( default , setter( into) ) ]
68+ checksum_algorithm : Option < crate :: s3:: utils:: ChecksumAlgorithm > ,
6269}
6370
6471impl S3Api for UploadPartCopy {
@@ -78,6 +85,7 @@ pub type UploadPartCopyBldr = UploadPartCopyBuilder<(
7885 ( String , ) ,
7986 ( ) ,
8087 ( ) ,
88+ ( ) ,
8189) > ;
8290
8391impl ToS3Request for UploadPartCopy {
@@ -100,6 +108,10 @@ impl ToS3Request for UploadPartCopy {
100108 let mut headers: Multimap = self . extra_headers . unwrap_or_default ( ) ;
101109 headers. add_multimap ( self . headers ) ;
102110
111+ if let Some ( algorithm) = self . checksum_algorithm {
112+ headers. add ( X_AMZ_CHECKSUM_ALGORITHM , algorithm. as_str ( ) . to_string ( ) ) ;
113+ }
114+
103115 let mut query_params: Multimap = self . extra_query_params . unwrap_or_default ( ) ;
104116 {
105117 query_params. add ( "partNumber" , self . part_number . to_string ( ) ) ;
@@ -150,6 +162,8 @@ pub struct CopyObjectInternal {
150162 metadata_directive : Option < Directive > ,
151163 #[ builder( default , setter( into) ) ]
152164 tagging_directive : Option < Directive > ,
165+ #[ builder( default , setter( into) ) ]
166+ checksum_algorithm : Option < crate :: s3:: utils:: ChecksumAlgorithm > ,
153167}
154168
155169impl S3Api for CopyObjectInternal {
@@ -175,6 +189,7 @@ pub type CopyObjectInternalBldr = CopyObjectInternalBuilder<(
175189 ( ) ,
176190 ( ) ,
177191 ( ) ,
192+ ( ) ,
178193) > ;
179194
180195impl ToS3Request for CopyObjectInternal {
@@ -261,6 +276,10 @@ impl ToS3Request for CopyObjectInternal {
261276 if let Some ( v) = self . source . ssec {
262277 headers. add_multimap ( v. copy_headers ( ) ) ;
263278 }
279+
280+ if let Some ( algorithm) = self . checksum_algorithm {
281+ headers. add ( X_AMZ_CHECKSUM_ALGORITHM , algorithm. as_str ( ) . to_string ( ) ) ;
282+ }
264283 } ;
265284
266285 Ok ( S3Request :: builder ( )
@@ -310,6 +329,13 @@ pub struct CopyObject {
310329 metadata_directive : Option < Directive > ,
311330 #[ builder( default , setter( into) ) ]
312331 tagging_directive : Option < Directive > ,
332+ /// Optional checksum algorithm for data integrity verification during copy.
333+ ///
334+ /// When specified, the server computes a checksum of the destination object using
335+ /// this algorithm during the copy operation. Supported algorithms: CRC32, CRC32C,
336+ /// SHA1, SHA256, CRC64NVME. The checksum value is included in response headers for verification.
337+ #[ builder( default , setter( into) ) ]
338+ checksum_algorithm : Option < crate :: s3:: utils:: ChecksumAlgorithm > ,
313339}
314340
315341/// Builder type for [`CopyObject`] that is returned by [`MinioClient::copy_object`](crate::s3::client::MinioClient::copy_object).
@@ -331,6 +357,7 @@ pub type CopyObjectBldr = CopyObjectBuilder<(
331357 ( ) ,
332358 ( ) ,
333359 ( ) ,
360+ ( ) ,
334361) > ;
335362
336363impl CopyObject {
@@ -434,6 +461,7 @@ impl CopyObject {
434461 . source ( self . source )
435462 . metadata_directive ( self . metadata_directive )
436463 . tagging_directive ( self . tagging_directive )
464+ . checksum_algorithm ( self . checksum_algorithm )
437465 . build ( )
438466 . send ( )
439467 . await ?;
@@ -629,6 +657,11 @@ impl ComposeObjectInternal {
629657 number : part_number,
630658 etag,
631659 size,
660+ checksum_crc32 : resp. get_checksum ( ChecksumAlgorithm :: CRC32 ) ,
661+ checksum_crc32c : resp. get_checksum ( ChecksumAlgorithm :: CRC32C ) ,
662+ checksum_sha1 : resp. get_checksum ( ChecksumAlgorithm :: SHA1 ) ,
663+ checksum_sha256 : resp. get_checksum ( ChecksumAlgorithm :: SHA256 ) ,
664+ checksum_crc64nvme : resp. get_checksum ( ChecksumAlgorithm :: CRC64NVME ) ,
632665 } ) ;
633666 } else {
634667 while size > 0 {
@@ -669,6 +702,11 @@ impl ComposeObjectInternal {
669702 number : part_number,
670703 etag,
671704 size,
705+ checksum_crc32 : resp. get_checksum ( ChecksumAlgorithm :: CRC32 ) ,
706+ checksum_crc32c : resp. get_checksum ( ChecksumAlgorithm :: CRC32C ) ,
707+ checksum_sha1 : resp. get_checksum ( ChecksumAlgorithm :: SHA1 ) ,
708+ checksum_sha256 : resp. get_checksum ( ChecksumAlgorithm :: SHA256 ) ,
709+ checksum_crc64nvme : resp. get_checksum ( ChecksumAlgorithm :: CRC64NVME ) ,
672710 } ) ;
673711
674712 offset += length;
0 commit comments