diff --git a/object_store/src/aws/client.rs b/object_store/src/aws/client.rs index 88258ac998dc..b6d6b62a16db 100644 --- a/object_store/src/aws/client.rs +++ b/object_store/src/aws/client.rs @@ -62,6 +62,7 @@ use std::sync::Arc; const VERSION_HEADER: &str = "x-amz-version-id"; const SHA256_CHECKSUM: &str = "x-amz-checksum-sha256"; const USER_DEFINED_METADATA_HEADER_PREFIX: &str = "x-amz-meta-"; +const ALGORITHM: &str = "x-amz-checksum-algorithm"; /// A specialized `Error` for object store-related errors #[derive(Debug, Snafu)] @@ -390,10 +391,9 @@ impl<'a> Request<'a> { let payload_sha256 = sha256.finish(); if let Some(Checksum::SHA256) = self.config.checksum { - self.builder = self.builder.header( - "x-amz-checksum-sha256", - BASE64_STANDARD.encode(payload_sha256), - ); + self.builder = self + .builder + .header(SHA256_CHECKSUM, BASE64_STANDARD.encode(payload_sha256)); } self.payload_sha256 = Some(payload_sha256); } @@ -617,11 +617,11 @@ impl S3Client { location: &Path, opts: PutMultipartOpts, ) -> Result { - let mut req = self.request(Method::POST, location); - if self.config.checksum == Some(Checksum::SHA256) { - req = req.header("x-amz-checksum-algorithm", "SHA256"); + let mut reqquest = self.request(Method::POST, location); + if let Some(algorithm) = self.config.checksum { + reqquest = reqquest.header(ALGORITHM, &algorithm.to_string().to_uppercase()); } - let response = req + let response = reqquest .query(&[("uploads", "")]) .with_encryption_headers() .with_attributes(opts.attributes) @@ -674,7 +674,7 @@ impl S3Client { let response = request.send().await?; let checksum = response .headers() - .get("x-amz-checksum-sha256") + .get(SHA256_CHECKSUM) .and_then(|v| v.to_str().ok()) .map(|v| v.to_string());