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 4625e0a1aa fix(services/azblob): preserve content disposition in
presigned writes (#9301)
4625e0a1aa is described below
commit 4625e0a1aad6d5115870587e3eb91f6f336b3013
Author: Xuanwo <[email protected]>
AuthorDate: Sat Nov 28 02:20:55 2026 +0800
fix(services/azblob): preserve content disposition in presigned writes
(#9301)
---
core/services/azblob/src/backend.rs | 21 +++++++++++++++++++++
core/services/azblob/src/core.rs | 4 ++++
2 files changed, 25 insertions(+)
diff --git a/core/services/azblob/src/backend.rs
b/core/services/azblob/src/backend.rs
index f5201a56ec..23e90e64e2 100644
--- a/core/services/azblob/src/backend.rs
+++ b/core/services/azblob/src/backend.rs
@@ -983,6 +983,26 @@ 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 [
op.presign_stat("path/to/file.txt",
std::time::Duration::from_secs(120))
.await
@@ -993,6 +1013,7 @@ mod tests {
op.presign_write("path/to/file.txt",
std::time::Duration::from_secs(120))
.await
.unwrap(),
+ upload,
] {
assert_eq!(req.uri().path(), "/test/path/to/file.txt");
assert!(
diff --git a/core/services/azblob/src/core.rs b/core/services/azblob/src/core.rs
index e4bde844ba..b88d56050e 100644
--- a/core/services/azblob/src/core.rs
+++ b/core/services/azblob/src/core.rs
@@ -327,6 +327,10 @@ impl AzblobCore {
req = req.header(CONTENT_TYPE, ty)
}
+ if let Some(disposition) = args.content_disposition() {
+ req = req.header("x-ms-blob-content-disposition", disposition);
+ }
+
// 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() {