Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
liugddx committed Sep 6, 2024
1 parent fa2acc4 commit 7be6398
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions core/src/services/lakefs/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,6 @@ impl LakefsCore {
let auth_header_content = format_authorization_by_basic(&self.username, &self.password)?;
req = req.header(header::AUTHORIZATION, auth_header_content);

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

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

if let Some(cache_control) = args.cache_control() {
req = req.header(CACHE_CONTROL, cache_control)
}
req = req.header(CONTENT_LENGTH, body.len());

let req = req.body(Buffer::new()).map_err(new_request_build_error)?;

let res = self.send(req).await?;
Expand All @@ -193,8 +180,23 @@ impl LakefsCore {
serde_json::from_reader(res.clone().into_body().reader())
.map_err(new_json_deserialize_error)?;

let req = Request::put(&res.presigned_url)
.body(body)
let mut req = Request::put(&res.presigned_url);
let auth_header_content = format_authorization_by_basic(&self.username, &self.password)?;
req = req.header(header::AUTHORIZATION, auth_header_content);
req = req.header(CONTENT_LENGTH, body.len());
if let Some(mime) = args.content_type() {
req = req.header(CONTENT_TYPE, mime)
}

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

if let Some(cache_control) = args.cache_control() {
req = req.header(CACHE_CONTROL, cache_control)
}
let mut req = Request::put(&res.presigned_url)
.body(body.clone())
.map_err(new_request_build_error)?;

Ok(req)
Expand Down

0 comments on commit 7be6398

Please sign in to comment.