Skip to content

Commit

Permalink
refactor(services/dropbox): Use OpWrite instead of passing all args a…
Browse files Browse the repository at this point in the history
…s parameters (apache#3126)
  • Loading branch information
ImSingee authored and Young-Flash committed Sep 19, 2023
1 parent b56c310 commit 62c1361
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions core/src/services/dropbox/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ impl DropboxCore {
&self,
path: &str,
size: Option<usize>,
content_type: Option<&str>,
args: &OpWrite,
body: AsyncBody,
) -> Result<Response<IncomingAsyncBody>> {
let url = "https://content.dropboxapi.com/2/files/upload".to_string();
let args = DropboxUploadArgs {
let dropbox_update_args = DropboxUploadArgs {
path: build_rooted_abs_path(&self.root, path),
..Default::default()
};
Expand All @@ -112,13 +112,13 @@ impl DropboxCore {
}
request_builder = request_builder.header(
CONTENT_TYPE,
content_type.unwrap_or("application/octet-stream"),
args.content_type().unwrap_or("application/octet-stream"),
);

let mut request = request_builder
.header(
"Dropbox-API-Arg",
serde_json::to_string(&args).map_err(new_json_serialize_error)?,
serde_json::to_string(&dropbox_update_args).map_err(new_json_serialize_error)?,
)
.body(body)
.map_err(new_request_build_error)?;
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/dropbox/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl oio::OneShotWrite for DropboxWriter {
.dropbox_update(
&self.path,
Some(bs.len()),
self.op.content_type(),
&self.op,
AsyncBody::ChunkedBytes(bs),
)
.await?;
Expand Down

0 comments on commit 62c1361

Please sign in to comment.