From 6187b6dd1ce3b9c2d2645bc6907ef32fafd5fdce Mon Sep 17 00:00:00 2001 From: Au Date: Thu, 14 Sep 2023 23:16:32 +0800 Subject: [PATCH] feat(services/azblob): Rewrite the method signatures using OpWrite (#3068) * feat(services/azblob)!: Rewrite the method signatures using OpWrite * chore(services/azblob): use OpWrite::default instead of Default::default --- core/src/services/azblob/backend.rs | 19 ++++++++++++------- core/src/services/azblob/core.rs | 14 ++++++-------- core/src/services/azblob/writer.rs | 11 ++++------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/core/src/services/azblob/backend.rs b/core/src/services/azblob/backend.rs index 3ba390c1302..967cdd7127b 100644 --- a/core/src/services/azblob/backend.rs +++ b/core/src/services/azblob/backend.rs @@ -557,9 +557,12 @@ impl Accessor for AzblobBackend { } async fn create_dir(&self, path: &str, _: OpCreateDir) -> Result { - let mut req = - self.core - .azblob_put_blob_request(path, Some(0), None, None, AsyncBody::Empty)?; + let mut req = self.core.azblob_put_blob_request( + path, + Some(0), + &OpWrite::default(), + AsyncBody::Empty, + )?; self.core.sign(&mut req).await?; @@ -682,10 +685,12 @@ impl Accessor for AzblobBackend { v.if_match(), v.override_content_disposition(), )?, - PresignOperation::Write(_) => { - self.core - .azblob_put_blob_request(path, None, None, None, AsyncBody::Empty)? - } + PresignOperation::Write(_) => self.core.azblob_put_blob_request( + path, + None, + &OpWrite::default(), + AsyncBody::Empty, + )?, }; self.core.sign_query(&mut req).await?; diff --git a/core/src/services/azblob/core.rs b/core/src/services/azblob/core.rs index 5eb46f4644f..e493ff1abe2 100644 --- a/core/src/services/azblob/core.rs +++ b/core/src/services/azblob/core.rs @@ -245,8 +245,7 @@ impl AzblobCore { &self, path: &str, size: Option, - content_type: Option<&str>, - cache_control: Option<&str>, + args: &OpWrite, body: AsyncBody, ) -> Result> { let p = build_abs_path(&self.root, path); @@ -263,14 +262,14 @@ impl AzblobCore { // Set SSE headers. req = self.insert_sse_headers(req); - if let Some(cache_control) = cache_control { + 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) } - if let Some(ty) = content_type { + if let Some(ty) = args.content_type() { req = req.header(CONTENT_TYPE, ty) } @@ -305,8 +304,7 @@ impl AzblobCore { pub fn azblob_init_appendable_blob_request( &self, path: &str, - content_type: Option<&str>, - cache_control: Option<&str>, + args: &OpWrite, ) -> Result> { let p = build_abs_path(&self.root, path); @@ -330,11 +328,11 @@ impl AzblobCore { "AppendBlob", ); - if let Some(ty) = content_type { + if let Some(ty) = args.content_type() { req = req.header(CONTENT_TYPE, ty) } - if let Some(cache_control) = cache_control { + if let Some(cache_control) = args.cache_control() { req = req.header(constants::X_MS_BLOB_CACHE_CONTROL, cache_control); } diff --git a/core/src/services/azblob/writer.rs b/core/src/services/azblob/writer.rs index 301c9f733ac..bfcde2007d4 100644 --- a/core/src/services/azblob/writer.rs +++ b/core/src/services/azblob/writer.rs @@ -50,8 +50,7 @@ impl oio::OneShotWrite for AzblobWriter { let mut req = self.core.azblob_put_blob_request( &self.path, Some(bs.len() as u64), - self.op.content_type(), - self.op.cache_control(), + &self.op, AsyncBody::ChunkedBytes(bs), )?; @@ -95,11 +94,9 @@ impl oio::AppendObjectWrite for AzblobWriter { Ok(parse_content_length(headers)?.unwrap_or_default()) } StatusCode::NOT_FOUND => { - let mut req = self.core.azblob_init_appendable_blob_request( - &self.path, - self.op.content_type(), - self.op.cache_control(), - )?; + let mut req = self + .core + .azblob_init_appendable_blob_request(&self.path, &self.op)?; self.core.sign(&mut req).await?;