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/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 4fac295b3 feat(services/obs): Rewrite method signatures using OpWrite
(#3075)
4fac295b3 is described below
commit 4fac295b3054407ffd7dbf8f33428cd2ea56ad55
Author: hanhotfox <[email protected]>
AuthorDate: Fri Sep 15 01:53:20 2023 +0800
feat(services/obs): Rewrite method signatures using OpWrite (#3075)
feat(services/obs): Rewrite obs_put_object_request signatures using OpWrite
---
core/src/services/obs/backend.rs | 20 ++++++++++----------
core/src/services/obs/core.rs | 8 ++++----
core/src/services/obs/writer.rs | 10 +++-------
3 files changed, 17 insertions(+), 21 deletions(-)
diff --git a/core/src/services/obs/backend.rs b/core/src/services/obs/backend.rs
index ab0a6b32e..1db5cc0a8 100644
--- a/core/src/services/obs/backend.rs
+++ b/core/src/services/obs/backend.rs
@@ -316,13 +316,10 @@ impl Accessor for ObsBackend {
v.if_match(),
v.if_none_match(),
)?,
- PresignOperation::Write(v) => self.core.obs_put_object_request(
- path,
- None,
- v.content_type(),
- v.cache_control(),
- AsyncBody::Empty,
- )?,
+ PresignOperation::Write(v) => {
+ self.core
+ .obs_put_object_request(path, None, v, AsyncBody::Empty)?
+ }
};
self.core.sign_query(&mut req, args.expire()).await?;
@@ -337,9 +334,12 @@ impl Accessor for ObsBackend {
}
async fn create_dir(&self, path: &str, _: OpCreateDir) ->
Result<RpCreateDir> {
- let mut req =
- self.core
- .obs_put_object_request(path, Some(0), None, None,
AsyncBody::Empty)?;
+ let mut req = self.core.obs_put_object_request(
+ path,
+ Some(0),
+ &OpWrite::default(),
+ AsyncBody::Empty,
+ )?;
self.core.sign(&mut req).await?;
diff --git a/core/src/services/obs/core.rs b/core/src/services/obs/core.rs
index e78bafce6..965f99427 100644
--- a/core/src/services/obs/core.rs
+++ b/core/src/services/obs/core.rs
@@ -151,8 +151,7 @@ impl ObsCore {
&self,
path: &str,
size: Option<u64>,
- content_type: Option<&str>,
- cache_control: Option<&str>,
+ args: &OpWrite,
body: AsyncBody,
) -> Result<Request<AsyncBody>> {
let p = build_abs_path(&self.root, path);
@@ -164,11 +163,11 @@ impl ObsCore {
if let Some(size) = size {
req = req.header(CONTENT_LENGTH, size)
}
- if let Some(cache_control) = cache_control {
+ if let Some(cache_control) = args.cache_control() {
req = req.header(CACHE_CONTROL, cache_control)
}
- if let Some(mime) = content_type {
+ if let Some(mime) = args.content_type() {
req = req.header(CONTENT_TYPE, mime)
}
@@ -439,6 +438,7 @@ impl ObsCore {
self.send(req).await
}
}
+
/// Result of CreateMultipartUpload
#[derive(Default, Debug, Deserialize)]
#[serde(default, rename_all = "PascalCase")]
diff --git a/core/src/services/obs/writer.rs b/core/src/services/obs/writer.rs
index 94b8380a7..3e0741c98 100644
--- a/core/src/services/obs/writer.rs
+++ b/core/src/services/obs/writer.rs
@@ -49,13 +49,9 @@ impl ObsWriter {
#[async_trait]
impl oio::MultipartUploadWrite for ObsWriter {
async fn write_once(&self, size: u64, body: AsyncBody) -> Result<()> {
- let mut req = self.core.obs_put_object_request(
- &self.path,
- Some(size),
- self.op.content_type(),
- self.op.cache_control(),
- body,
- )?;
+ let mut req = self
+ .core
+ .obs_put_object_request(&self.path, Some(size), &self.op, body)?;
self.core.sign(&mut req).await?;