This is an automated email from the ASF dual-hosted git repository.

Xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 41530d4d8a fix(services/azblob): preserve content encoding and 
language on Put Blob (#9303)
41530d4d8a is described below

commit 41530d4d8ac90b6f6e191ed9296767fb37332e68
Author: Xuanwo <[email protected]>
AuthorDate: Sat Nov 28 03:29:01 2026 +0800

    fix(services/azblob): preserve content encoding and language on Put Blob 
(#9303)
---
 core/services/azblob/src/backend.rs | 60 +++++++++++++++++++++++--------------
 core/services/azblob/src/core.rs    |  8 +++++
 2 files changed, 46 insertions(+), 22 deletions(-)

diff --git a/core/services/azblob/src/backend.rs 
b/core/services/azblob/src/backend.rs
index 23e90e64e2..db89c111a3 100644
--- a/core/services/azblob/src/backend.rs
+++ b/core/services/azblob/src/backend.rs
@@ -983,27 +983,7 @@ mod tests {
             assert!(cap.presign_write);
             assert!(!cap.presign_delete);
 
-            let disposition = "attachment; filename=\"test.txt\"";
-            let upload = op
-                .presign_write_options(
-                    "path/to/file.txt",
-                    std::time::Duration::from_secs(120),
-                    options::WriteOptions {
-                        content_disposition: Some(disposition.to_owned()),
-                        ..Default::default()
-                    },
-                )
-                .await
-                .unwrap();
-            assert_eq!(
-                upload
-                    .header()
-                    .get("x-ms-blob-content-disposition")
-                    .and_then(|value| value.to_str().ok()),
-                Some(disposition)
-            );
-
-            for req in [
+            let mut requests = vec![
                 op.presign_stat("path/to/file.txt", 
std::time::Duration::from_secs(120))
                     .await
                     .unwrap(),
@@ -1013,8 +993,44 @@ mod tests {
                 op.presign_write("path/to/file.txt", 
std::time::Duration::from_secs(120))
                     .await
                     .unwrap(),
-                upload,
+            ];
+
+            let disposition = "attachment; filename=\"test.txt\"";
+            for (encoding, language) in [
+                (Some("gzip"), Some("fr-CA")),
+                (Some("gzip"), None),
+                (None, Some("fr-CA")),
+                (None, None),
             ] {
+                let upload = op
+                    .presign_write_options(
+                        "path/to/file.txt",
+                        std::time::Duration::from_secs(120),
+                        options::WriteOptions {
+                            content_disposition: Some(disposition.to_owned()),
+                            content_encoding: encoding.map(str::to_owned),
+                            content_language: language.map(str::to_owned),
+                            ..Default::default()
+                        },
+                    )
+                    .await
+                    .unwrap();
+
+                for (name, expected) in [
+                    ("x-ms-blob-content-disposition", Some(disposition)),
+                    ("x-ms-blob-content-encoding", encoding),
+                    ("x-ms-blob-content-language", language),
+                ] {
+                    assert_eq!(
+                        
upload.header().get(name).map(http::HeaderValue::as_bytes),
+                        expected.map(str::as_bytes),
+                        "{name} with encoding={encoding:?}, 
language={language:?}"
+                    );
+                }
+                requests.push(upload);
+            }
+
+            for req in requests {
                 assert_eq!(req.uri().path(), "/test/path/to/file.txt");
                 assert!(
                     !req.header()
diff --git a/core/services/azblob/src/core.rs b/core/services/azblob/src/core.rs
index b88d56050e..905ea64de4 100644
--- a/core/services/azblob/src/core.rs
+++ b/core/services/azblob/src/core.rs
@@ -331,6 +331,14 @@ impl AzblobCore {
             req = req.header("x-ms-blob-content-disposition", disposition);
         }
 
+        if let Some(encoding) = args.content_encoding() {
+            req = req.header("x-ms-blob-content-encoding", encoding);
+        }
+
+        if let Some(language) = args.content_language() {
+            req = req.header("x-ms-blob-content-language", language);
+        }
+
         // Specify the wildcard character (*) to perform the operation only if
         // the resource does not exist, and fail the operation if it does 
exist.
         if args.if_not_exists() {

Reply via email to