From 23bb518e97fcf5600bdc1a318932ff3ee9816427 Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Sat, 2 Nov 2024 10:21:35 +0100 Subject: [PATCH 01/12] feat: add user metadata for azblob --- core/src/services/azblob/backend.rs | 25 ++++++++++++++++++++++++- core/src/services/azblob/core.rs | 19 ++++++++++++++++--- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/core/src/services/azblob/backend.rs b/core/src/services/azblob/backend.rs index 8f905e3efe69..53e44632bf83 100644 --- a/core/src/services/azblob/backend.rs +++ b/core/src/services/azblob/backend.rs @@ -33,6 +33,7 @@ use reqsign::AzureStorageSigner; use sha2::Digest; use sha2::Sha256; +use super::core::constants; use super::error::parse_error; use super::lister::AzblobLister; use super::writer::AzblobWriter; @@ -517,6 +518,7 @@ impl Access for AzblobBackend { write_can_multi: true, write_with_cache_control: true, write_with_content_type: true, + write_with_user_metadata: true, delete: true, copy: true, @@ -545,7 +547,28 @@ impl Access for AzblobBackend { let status = resp.status(); match status { - StatusCode::OK => parse_into_metadata(path, resp.headers()).map(RpStat::new), + StatusCode::OK => { + let headers = resp.headers(); + let mut meta = parse_into_metadata(path, headers)?; + // TODO: Refactor in common with s3 metadata parsing + // do the same as in parse_into_metadata... but for user metadata + let user_meta: HashMap = headers + .iter() + .filter_map(|(name, _)| { + name.as_str() + .strip_prefix(constants::X_MS_META_NAME_PREFIX) + .and_then(|stripped_key| { + parse_header_to_str(headers, name) + .unwrap_or(None) + .map(|val| (stripped_key.to_string(), val.to_string())) + }) + }) + .collect(); + if !user_meta.is_empty() { + meta.with_user_metadata(user_meta); + } + return Ok(RpStat::new(meta)); + } _ => Err(parse_error(resp)), } } diff --git a/core/src/services/azblob/core.rs b/core/src/services/azblob/core.rs index c4c1925704bd..be6e257b8985 100644 --- a/core/src/services/azblob/core.rs +++ b/core/src/services/azblob/core.rs @@ -42,13 +42,14 @@ use uuid::Uuid; use crate::raw::*; use crate::*; -mod constants { +pub mod constants { pub const X_MS_VERSION: &str = "x-ms-version"; pub const X_MS_BLOB_TYPE: &str = "x-ms-blob-type"; pub const X_MS_COPY_SOURCE: &str = "x-ms-copy-source"; pub const X_MS_BLOB_CACHE_CONTROL: &str = "x-ms-blob-cache-control"; pub const X_MS_BLOB_CONDITION_APPENDPOS: &str = "x-ms-blob-condition-appendpos"; + pub const X_MS_META_NAME_PREFIX: &str = "x-ms-meta-name:"; // Server-side encryption with customer-provided headers pub const X_MS_ENCRYPTION_KEY: &str = "x-ms-encryption-key"; @@ -235,7 +236,7 @@ impl AzblobCore { let p = build_abs_path(&self.root, path); let url = format!( - "{}/{}/{}", + "{}/{}/{}?comp=metadata", self.endpoint, self.container, percent_encode_path(&p) @@ -243,6 +244,18 @@ impl AzblobCore { let mut req = Request::put(&url); + // Set user metadata headers. + // TODO: refactor this and the s3 backend to use an utils function instead + // TODO: only for put_blobs or also block requests? + if let Some(user_metadata) = args.user_metadata() { + for (key, value) in user_metadata { + req = req.header( + format!("{}{}", constants::X_MS_META_NAME_PREFIX, key), + value, + ) + } + } + // Set SSE headers. req = self.insert_sse_headers(req); @@ -480,7 +493,7 @@ impl AzblobCore { let p = build_abs_path(&self.root, path); let url = format!( - "{}/{}/{}", + "{}/{}/{}?comp=metadata", self.endpoint, self.container, percent_encode_path(&p) From 4c6476a5ebb99533bbc740fab14fee01f8523b14 Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Sat, 2 Nov 2024 10:45:15 +0100 Subject: [PATCH 02/12] refactor: az user metadata --- core/src/services/azblob/core.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/src/services/azblob/core.rs b/core/src/services/azblob/core.rs index be6e257b8985..989aa04fcaee 100644 --- a/core/src/services/azblob/core.rs +++ b/core/src/services/azblob/core.rs @@ -24,6 +24,7 @@ use std::time::Duration; use base64::prelude::BASE64_STANDARD; use base64::Engine; use bytes::Bytes; +use constants::X_MS_META_NAME_PREFIX; use http::header::HeaderName; use http::header::CONTENT_LENGTH; use http::header::CONTENT_TYPE; @@ -49,7 +50,7 @@ pub mod constants { pub const X_MS_COPY_SOURCE: &str = "x-ms-copy-source"; pub const X_MS_BLOB_CACHE_CONTROL: &str = "x-ms-blob-cache-control"; pub const X_MS_BLOB_CONDITION_APPENDPOS: &str = "x-ms-blob-condition-appendpos"; - pub const X_MS_META_NAME_PREFIX: &str = "x-ms-meta-name:"; + pub const X_MS_META_NAME_PREFIX: &str = "x-ms-meta-"; // Server-side encryption with customer-provided headers pub const X_MS_ENCRYPTION_KEY: &str = "x-ms-encryption-key"; @@ -235,13 +236,17 @@ impl AzblobCore { ) -> Result> { let p = build_abs_path(&self.root, path); - let url = format!( - "{}/{}/{}?comp=metadata", + let mut url = format!( + "{}/{}/{}", self.endpoint, self.container, percent_encode_path(&p) ); + if let Some(_) = args.user_metadata() { + url.push_str("?comp=metadata"); + } + let mut req = Request::put(&url); // Set user metadata headers. @@ -249,10 +254,7 @@ impl AzblobCore { // TODO: only for put_blobs or also block requests? if let Some(user_metadata) = args.user_metadata() { for (key, value) in user_metadata { - req = req.header( - format!("{}{}", constants::X_MS_META_NAME_PREFIX, key), - value, - ) + req = req.header(format!("{X_MS_META_NAME_PREFIX}{key}"), value) } } From 398efed69fd2d3436718e987f689e90267715cc4 Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Sat, 2 Nov 2024 10:47:13 +0100 Subject: [PATCH 03/12] fix: clippy lint --- core/src/services/azblob/backend.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/services/azblob/backend.rs b/core/src/services/azblob/backend.rs index 53e44632bf83..8da8f936ee35 100644 --- a/core/src/services/azblob/backend.rs +++ b/core/src/services/azblob/backend.rs @@ -567,7 +567,7 @@ impl Access for AzblobBackend { if !user_meta.is_empty() { meta.with_user_metadata(user_meta); } - return Ok(RpStat::new(meta)); + Ok(RpStat::new(meta)) } _ => Err(parse_error(resp)), } From 39e4d626d29f06d7085b032a8148dd187f77b8a4 Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Sat, 2 Nov 2024 10:59:10 +0100 Subject: [PATCH 04/12] test: fix broken tests --- core/src/services/azblob/backend.rs | 1 + core/src/services/azblob/core.rs | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/core/src/services/azblob/backend.rs b/core/src/services/azblob/backend.rs index 8da8f936ee35..af8d0fc9ecec 100644 --- a/core/src/services/azblob/backend.rs +++ b/core/src/services/azblob/backend.rs @@ -549,6 +549,7 @@ impl Access for AzblobBackend { match status { StatusCode::OK => { let headers = resp.headers(); + dbg!(&headers); let mut meta = parse_into_metadata(path, headers)?; // TODO: Refactor in common with s3 metadata parsing // do the same as in parse_into_metadata... but for user metadata diff --git a/core/src/services/azblob/core.rs b/core/src/services/azblob/core.rs index 989aa04fcaee..55f415bfe07e 100644 --- a/core/src/services/azblob/core.rs +++ b/core/src/services/azblob/core.rs @@ -236,17 +236,13 @@ impl AzblobCore { ) -> Result> { let p = build_abs_path(&self.root, path); - let mut url = format!( + let url = format!( "{}/{}/{}", self.endpoint, self.container, percent_encode_path(&p) ); - if let Some(_) = args.user_metadata() { - url.push_str("?comp=metadata"); - } - let mut req = Request::put(&url); // Set user metadata headers. @@ -264,6 +260,7 @@ impl AzblobCore { if let Some(cache_control) = args.cache_control() { req = req.header(constants::X_MS_BLOB_CACHE_CONTROL, cache_control); } + if let Some(size) = size { req = req.header(CONTENT_LENGTH, size) } @@ -495,7 +492,7 @@ impl AzblobCore { let p = build_abs_path(&self.root, path); let url = format!( - "{}/{}/{}?comp=metadata", + "{}/{}/{}", self.endpoint, self.container, percent_encode_path(&p) From 72e6e109425b946a2d7d70e1496f6a1571bb5d15 Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Sat, 2 Nov 2024 10:59:31 +0100 Subject: [PATCH 05/12] chore: remove dbg statement --- core/src/services/azblob/backend.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/services/azblob/backend.rs b/core/src/services/azblob/backend.rs index af8d0fc9ecec..8da8f936ee35 100644 --- a/core/src/services/azblob/backend.rs +++ b/core/src/services/azblob/backend.rs @@ -549,7 +549,6 @@ impl Access for AzblobBackend { match status { StatusCode::OK => { let headers = resp.headers(); - dbg!(&headers); let mut meta = parse_into_metadata(path, headers)?; // TODO: Refactor in common with s3 metadata parsing // do the same as in parse_into_metadata... but for user metadata From 155bb1a3f90650da01b95375834a485675e80de3 Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Sat, 2 Nov 2024 11:02:11 +0100 Subject: [PATCH 06/12] chore: remove comment --- core/src/services/azblob/core.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/services/azblob/core.rs b/core/src/services/azblob/core.rs index 55f415bfe07e..64bb3f0071ce 100644 --- a/core/src/services/azblob/core.rs +++ b/core/src/services/azblob/core.rs @@ -245,7 +245,6 @@ impl AzblobCore { let mut req = Request::put(&url); - // Set user metadata headers. // TODO: refactor this and the s3 backend to use an utils function instead // TODO: only for put_blobs or also block requests? if let Some(user_metadata) = args.user_metadata() { From 19279327a73ffa70f4c5079fd149ab82f7649e15 Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Sat, 2 Nov 2024 12:48:59 +0100 Subject: [PATCH 07/12] refactor: refactor prefixed headers parsing --- core/src/raw/http_util/header.rs | 17 +++++++++++++++++ core/src/raw/http_util/mod.rs | 1 + core/src/services/azblob/backend.rs | 18 ++++-------------- core/src/services/s3/backend.rs | 14 ++------------ 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/core/src/raw/http_util/header.rs b/core/src/raw/http_util/header.rs index 87748c96f4db..49dff81a0ff7 100644 --- a/core/src/raw/http_util/header.rs +++ b/core/src/raw/http_util/header.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +use std::collections::HashMap; + use base64::engine::general_purpose; use base64::Engine; use chrono::DateTime; @@ -189,6 +191,21 @@ pub fn parse_into_metadata(path: &str, headers: &HeaderMap) -> Result Ok(m) } +/// Parse prefixed headers and return a map with the prefix of each header removed. +pub fn parse_prefixed_headers(headers: &HeaderMap, prefix: &str) -> HashMap { + headers + .iter() + .filter_map(|(name, value)| { + name.as_str().strip_prefix(prefix).and_then(|stripped_key| { + value + .to_str() + .ok() + .map(|parsed_value| (stripped_key.to_string(), parsed_value.to_string())) + }) + }) + .collect() +} + /// format content md5 header by given input. pub fn format_content_md5(bs: &[u8]) -> String { let mut hasher = md5::Md5::new(); diff --git a/core/src/raw/http_util/mod.rs b/core/src/raw/http_util/mod.rs index 226fb17b7d47..8999b6b807f0 100644 --- a/core/src/raw/http_util/mod.rs +++ b/core/src/raw/http_util/mod.rs @@ -49,6 +49,7 @@ pub use header::parse_header_to_str; pub use header::parse_into_metadata; pub use header::parse_last_modified; pub use header::parse_location; +pub use header::parse_prefixed_headers; mod uri; pub use uri::percent_decode_path; diff --git a/core/src/services/azblob/backend.rs b/core/src/services/azblob/backend.rs index 8da8f936ee35..90c57de584e1 100644 --- a/core/src/services/azblob/backend.rs +++ b/core/src/services/azblob/backend.rs @@ -34,6 +34,7 @@ use sha2::Digest; use sha2::Sha256; use super::core::constants; +use super::core::constants::X_MS_META_NAME_PREFIX; use super::error::parse_error; use super::lister::AzblobLister; use super::writer::AzblobWriter; @@ -550,23 +551,12 @@ impl Access for AzblobBackend { StatusCode::OK => { let headers = resp.headers(); let mut meta = parse_into_metadata(path, headers)?; - // TODO: Refactor in common with s3 metadata parsing - // do the same as in parse_into_metadata... but for user metadata - let user_meta: HashMap = headers - .iter() - .filter_map(|(name, _)| { - name.as_str() - .strip_prefix(constants::X_MS_META_NAME_PREFIX) - .and_then(|stripped_key| { - parse_header_to_str(headers, name) - .unwrap_or(None) - .map(|val| (stripped_key.to_string(), val.to_string())) - }) - }) - .collect(); + + let user_meta = parse_prefixed_headers(&headers, X_MS_META_NAME_PREFIX); if !user_meta.is_empty() { meta.with_user_metadata(user_meta); } + Ok(RpStat::new(meta)) } _ => Err(parse_error(resp)), diff --git a/core/src/services/s3/backend.rs b/core/src/services/s3/backend.rs index 57b3a2f2fa46..525add77d75e 100644 --- a/core/src/services/s3/backend.rs +++ b/core/src/services/s3/backend.rs @@ -26,6 +26,7 @@ use std::sync::Arc; use base64::prelude::BASE64_STANDARD; use base64::Engine; use bytes::Buf; +use constants::X_AMZ_META_PREFIX; use http::Response; use http::StatusCode; use log::debug; @@ -970,18 +971,7 @@ impl Access for S3Backend { let headers = resp.headers(); let mut meta = parse_into_metadata(path, headers)?; - let user_meta: HashMap = headers - .iter() - .filter_map(|(name, _)| { - name.as_str() - .strip_prefix(constants::X_AMZ_META_PREFIX) - .and_then(|stripped_key| { - parse_header_to_str(headers, name) - .unwrap_or(None) - .map(|val| (stripped_key.to_string(), val.to_string())) - }) - }) - .collect(); + let user_meta = parse_prefixed_headers(&headers, X_AMZ_META_PREFIX); if !user_meta.is_empty() { meta.with_user_metadata(user_meta); } From 4282d5dcf7a33c12eaf5ddc1fdb9386a139a4408 Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Sat, 2 Nov 2024 12:54:27 +0100 Subject: [PATCH 08/12] chore: remove todos --- core/src/services/azblob/core.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/src/services/azblob/core.rs b/core/src/services/azblob/core.rs index 64bb3f0071ce..b0386c75e264 100644 --- a/core/src/services/azblob/core.rs +++ b/core/src/services/azblob/core.rs @@ -245,8 +245,6 @@ impl AzblobCore { let mut req = Request::put(&url); - // TODO: refactor this and the s3 backend to use an utils function instead - // TODO: only for put_blobs or also block requests? if let Some(user_metadata) = args.user_metadata() { for (key, value) in user_metadata { req = req.header(format!("{X_MS_META_NAME_PREFIX}{key}"), value) From d28eae6f0ff88761918db694d9da8f2bb7b2c60a Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Sat, 2 Nov 2024 12:56:51 +0100 Subject: [PATCH 09/12] style: use string interpolation in s3 metadata --- core/src/services/s3/core.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/services/s3/core.rs b/core/src/services/s3/core.rs index 79ba66239235..944dac8921b5 100644 --- a/core/src/services/s3/core.rs +++ b/core/src/services/s3/core.rs @@ -27,6 +27,7 @@ use std::time::Duration; use base64::prelude::BASE64_STANDARD; use base64::Engine; use bytes::Bytes; +use constants::X_AMZ_META_PREFIX; use http::header::HeaderName; use http::header::CACHE_CONTROL; use http::header::CONTENT_DISPOSITION; @@ -462,7 +463,7 @@ impl S3Core { // Set user metadata headers. if let Some(user_metadata) = args.user_metadata() { for (key, value) in user_metadata { - req = req.header(format!("{}{}", constants::X_AMZ_META_PREFIX, key), value) + req = req.header(format!("{X_AMZ_META_PREFIX}{key}"), value) } } From 4d6057ba266a2a71182a2d547d8665a9892a5787 Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Sat, 2 Nov 2024 13:21:25 +0100 Subject: [PATCH 10/12] refactor: apply parse_prefixed_metadata for oss --- core/src/services/azblob/backend.rs | 1 - core/src/services/oss/backend.rs | 4 +--- core/src/services/oss/core.rs | 29 ++++++----------------------- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/core/src/services/azblob/backend.rs b/core/src/services/azblob/backend.rs index 90c57de584e1..4f733593ccd5 100644 --- a/core/src/services/azblob/backend.rs +++ b/core/src/services/azblob/backend.rs @@ -33,7 +33,6 @@ use reqsign::AzureStorageSigner; use sha2::Digest; use sha2::Sha256; -use super::core::constants; use super::core::constants::X_MS_META_NAME_PREFIX; use super::error::parse_error; use super::lister::AzblobLister; diff --git a/core/src/services/oss/backend.rs b/core/src/services/oss/backend.rs index 7e2d67b3caf5..a627e1d4a0d8 100644 --- a/core/src/services/oss/backend.rs +++ b/core/src/services/oss/backend.rs @@ -489,9 +489,7 @@ impl Access for OssBackend { match status { StatusCode::OK => { let headers = resp.headers(); - let mut meta = - self.core - .parse_metadata(path, constants::X_OSS_META_PREFIX, resp.headers())?; + let mut meta = self.core.parse_metadata(path, resp.headers())?; if let Some(v) = parse_header_to_str(headers, "x-oss-version-id")? { meta.set_version(v); diff --git a/core/src/services/oss/core.rs b/core/src/services/oss/core.rs index d4dff76348e3..855542770767 100644 --- a/core/src/services/oss/core.rs +++ b/core/src/services/oss/core.rs @@ -15,13 +15,13 @@ // specific language governing permissions and limitations // under the License. -use std::collections::HashMap; use std::fmt::Debug; use std::fmt::Formatter; use std::fmt::Write; use std::time::Duration; use bytes::Bytes; +use constants::X_OSS_META_PREFIX; use http::header::CACHE_CONTROL; use http::header::CONTENT_DISPOSITION; use http::header::CONTENT_LENGTH; @@ -190,7 +190,7 @@ impl OssCore { "the format of the user metadata key is invalid, please refer the document", )); } - req = req.header(format!("{}{}", constants::X_OSS_META_PREFIX, key), value) + req = req.header(format!("{X_OSS_META_PREFIX}{key}"), value) } } @@ -213,28 +213,11 @@ impl OssCore { /// # Notes /// /// before return the user defined metadata, we'll strip the user_metadata_prefix from the key - pub fn parse_metadata( - &self, - path: &str, - user_metadata_prefix: &str, - headers: &HeaderMap, - ) -> Result { + pub fn parse_metadata(&self, path: &str, headers: &HeaderMap) -> Result { let mut m = parse_into_metadata(path, headers)?; - - let data: HashMap = headers - .iter() - .filter_map(|(key, _)| { - key.as_str() - .strip_prefix(user_metadata_prefix) - .and_then(|stripped_key| { - parse_header_to_str(headers, key) - .unwrap_or(None) - .map(|val| (stripped_key.to_string(), val.to_string())) - }) - }) - .collect(); - if !data.is_empty() { - m.with_user_metadata(data); + let user_meta = parse_prefixed_headers(&headers, X_OSS_META_PREFIX); + if !user_meta.is_empty() { + m.with_user_metadata(user_meta); } Ok(m) From 3228bd2186d29aec0cab86beb2cead7668b6529d Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Sat, 2 Nov 2024 13:29:14 +0100 Subject: [PATCH 11/12] fix: clippy lint --- core/src/services/azblob/backend.rs | 2 +- core/src/services/oss/core.rs | 2 +- core/src/services/s3/backend.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/services/azblob/backend.rs b/core/src/services/azblob/backend.rs index 4f733593ccd5..6a464c9fdd24 100644 --- a/core/src/services/azblob/backend.rs +++ b/core/src/services/azblob/backend.rs @@ -551,7 +551,7 @@ impl Access for AzblobBackend { let headers = resp.headers(); let mut meta = parse_into_metadata(path, headers)?; - let user_meta = parse_prefixed_headers(&headers, X_MS_META_NAME_PREFIX); + let user_meta = parse_prefixed_headers(headers, X_MS_META_NAME_PREFIX); if !user_meta.is_empty() { meta.with_user_metadata(user_meta); } diff --git a/core/src/services/oss/core.rs b/core/src/services/oss/core.rs index 855542770767..2a471ef8ce10 100644 --- a/core/src/services/oss/core.rs +++ b/core/src/services/oss/core.rs @@ -215,7 +215,7 @@ impl OssCore { /// before return the user defined metadata, we'll strip the user_metadata_prefix from the key pub fn parse_metadata(&self, path: &str, headers: &HeaderMap) -> Result { let mut m = parse_into_metadata(path, headers)?; - let user_meta = parse_prefixed_headers(&headers, X_OSS_META_PREFIX); + let user_meta = parse_prefixed_headers(headers, X_OSS_META_PREFIX); if !user_meta.is_empty() { m.with_user_metadata(user_meta); } diff --git a/core/src/services/s3/backend.rs b/core/src/services/s3/backend.rs index 525add77d75e..43f266e7c6a4 100644 --- a/core/src/services/s3/backend.rs +++ b/core/src/services/s3/backend.rs @@ -971,7 +971,7 @@ impl Access for S3Backend { let headers = resp.headers(); let mut meta = parse_into_metadata(path, headers)?; - let user_meta = parse_prefixed_headers(&headers, X_AMZ_META_PREFIX); + let user_meta = parse_prefixed_headers(headers, X_AMZ_META_PREFIX); if !user_meta.is_empty() { meta.with_user_metadata(user_meta); } From d76c46d18ac0b62c46669fbf20c4b31e8e3413fe Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Sat, 2 Nov 2024 13:57:45 +0100 Subject: [PATCH 12/12] feat: rename ms meta prefix constant --- core/src/services/azblob/backend.rs | 4 ++-- core/src/services/azblob/core.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/services/azblob/backend.rs b/core/src/services/azblob/backend.rs index 6a464c9fdd24..638513249582 100644 --- a/core/src/services/azblob/backend.rs +++ b/core/src/services/azblob/backend.rs @@ -33,7 +33,7 @@ use reqsign::AzureStorageSigner; use sha2::Digest; use sha2::Sha256; -use super::core::constants::X_MS_META_NAME_PREFIX; +use super::core::constants::X_MS_META_PREFIX; use super::error::parse_error; use super::lister::AzblobLister; use super::writer::AzblobWriter; @@ -551,7 +551,7 @@ impl Access for AzblobBackend { let headers = resp.headers(); let mut meta = parse_into_metadata(path, headers)?; - let user_meta = parse_prefixed_headers(headers, X_MS_META_NAME_PREFIX); + let user_meta = parse_prefixed_headers(headers, X_MS_META_PREFIX); if !user_meta.is_empty() { meta.with_user_metadata(user_meta); } diff --git a/core/src/services/azblob/core.rs b/core/src/services/azblob/core.rs index b0386c75e264..867f07651a4f 100644 --- a/core/src/services/azblob/core.rs +++ b/core/src/services/azblob/core.rs @@ -24,7 +24,7 @@ use std::time::Duration; use base64::prelude::BASE64_STANDARD; use base64::Engine; use bytes::Bytes; -use constants::X_MS_META_NAME_PREFIX; +use constants::X_MS_META_PREFIX; use http::header::HeaderName; use http::header::CONTENT_LENGTH; use http::header::CONTENT_TYPE; @@ -50,7 +50,7 @@ pub mod constants { pub const X_MS_COPY_SOURCE: &str = "x-ms-copy-source"; pub const X_MS_BLOB_CACHE_CONTROL: &str = "x-ms-blob-cache-control"; pub const X_MS_BLOB_CONDITION_APPENDPOS: &str = "x-ms-blob-condition-appendpos"; - pub const X_MS_META_NAME_PREFIX: &str = "x-ms-meta-"; + pub const X_MS_META_PREFIX: &str = "x-ms-meta-"; // Server-side encryption with customer-provided headers pub const X_MS_ENCRYPTION_KEY: &str = "x-ms-encryption-key"; @@ -247,7 +247,7 @@ impl AzblobCore { if let Some(user_metadata) = args.user_metadata() { for (key, value) in user_metadata { - req = req.header(format!("{X_MS_META_NAME_PREFIX}{key}"), value) + req = req.header(format!("{X_MS_META_PREFIX}{key}"), value) } }