Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(services/s3): Rewrite the method signatures using OpWrite #3078

Merged
merged 4 commits into from
Sep 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions core/src/services/s3/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,7 @@ impl S3Core {
&self,
path: &str,
size: Option<u64>,
content_type: Option<&str>,
content_disposition: Option<&str>,
cache_control: Option<&str>,
args: &OpWrite,
body: AsyncBody,
) -> Result<Request<AsyncBody>> {
let p = build_abs_path(&self.root, path);
Expand All @@ -351,15 +349,15 @@ impl S3Core {
req = req.header(CONTENT_LENGTH, size)
}

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 @@ -517,25 +515,23 @@ impl S3Core {
pub async fn s3_initiate_multipart_upload(
&self,
path: &str,
content_type: Option<&str>,
content_disposition: Option<&str>,
cache_control: Option<&str>,
args: &OpWrite,
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved
) -> Result<Response<IncomingAsyncBody>> {
let p = build_abs_path(&self.root, path);

let url = format!("{}/{}?uploads", self.endpoint, percent_encode_path(&p));

let mut req = Request::post(&url);

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

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

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

Expand Down
Loading