Skip to content

Commit

Permalink
refactor(services/oss): Refactor oss_put_object signatures by using O…
Browse files Browse the repository at this point in the history
…pWrite
  • Loading branch information
sysu-yunz committed Sep 15, 2023
1 parent d30ff84 commit 491b397
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
6 changes: 2 additions & 4 deletions core/src/services/oss/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ impl Accessor for OssBackend {
async fn create_dir(&self, path: &str, _: OpCreateDir) -> Result<RpCreateDir> {
let resp = self
.core
.oss_put_object(path, None, None, None, None, AsyncBody::Empty)
.oss_put_object(path, None, &OpWrite::default(), AsyncBody::Empty)
.await?;
let status = resp.status();

Expand Down Expand Up @@ -559,9 +559,7 @@ impl Accessor for OssBackend {
PresignOperation::Write(v) => self.core.oss_put_object_request(
path,
None,
v.content_type(),
v.content_disposition(),
v.cache_control(),
v,
AsyncBody::Empty,
true,
)?,
Expand Down
18 changes: 6 additions & 12 deletions core/src/services/oss/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ impl OssCore {
&self,
path: &str,
size: Option<u64>,
content_type: Option<&str>,
content_disposition: Option<&str>,
cache_control: Option<&str>,
args: &OpWrite,
body: AsyncBody,
is_presign: bool,
) -> Result<Request<AsyncBody>> {
Expand All @@ -166,15 +164,15 @@ impl OssCore {

req = req.header(CONTENT_LENGTH, size.unwrap_or_default());

if let Some(mime) = content_type {
if let Some(mime) = args.content_type() {
req = req.header(CONTENT_TYPE, mime);
}

if let Some(pos) = content_disposition {
if let Some(pos) = args.content_disposition() {
req = req.header(CONTENT_DISPOSITION, pos);
}

if let Some(cache_control) = cache_control {
if let Some(cache_control) = args.cache_control() {
req = req.header(CACHE_CONTROL, cache_control)
}

Expand Down Expand Up @@ -376,17 +374,13 @@ impl OssCore {
&self,
path: &str,
size: Option<u64>,
content_type: Option<&str>,
content_disposition: Option<&str>,
cache_control: Option<&str>,
args: &OpWrite,
body: AsyncBody,
) -> Result<Response<IncomingAsyncBody>> {
let mut req = self.oss_put_object_request(
path,
size,
content_type,
content_disposition,
cache_control,
args,
body,
false,
)?;
Expand Down
4 changes: 1 addition & 3 deletions core/src/services/oss/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ impl oio::MultipartUploadWrite for OssWriter {
let mut req = self.core.oss_put_object_request(
&self.path,
Some(size),
self.op.content_type(),
self.op.content_disposition(),
self.op.cache_control(),
&self.op,
body,
false,
)?;
Expand Down

0 comments on commit 491b397

Please sign in to comment.