fix review comments
This commit is contained in:
parent
19ac5ce20f
commit
e0aee72a9c
1 changed files with 187 additions and 184 deletions
|
@ -43,7 +43,14 @@ pub async fn handle_post_object(
|
||||||
let mut multipart = Multipart::with_constraints(body, boundary, constraints);
|
let mut multipart = Multipart::with_constraints(body, boundary, constraints);
|
||||||
|
|
||||||
let mut params = HeaderMap::new();
|
let mut params = HeaderMap::new();
|
||||||
while let Some(field) = multipart.next_field().await? {
|
let field = loop {
|
||||||
|
let field = if let Some(field) = multipart.next_field().await? {
|
||||||
|
field
|
||||||
|
} else {
|
||||||
|
return Err(Error::BadRequest(
|
||||||
|
"Request did not contain a file".to_owned(),
|
||||||
|
));
|
||||||
|
};
|
||||||
let name: HeaderName = if let Some(Ok(name)) = field.name().map(TryInto::try_into) {
|
let name: HeaderName = if let Some(Ok(name)) = field.name().map(TryInto::try_into) {
|
||||||
name
|
name
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,8 +69,10 @@ pub async fn handle_post_object(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
} else {
|
||||||
|
break field;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Current part is file. Do some checks before handling to PutObject code
|
// Current part is file. Do some checks before handling to PutObject code
|
||||||
let key = params
|
let key = params
|
||||||
|
@ -235,7 +244,6 @@ pub async fn handle_post_object(
|
||||||
.and_then(|h| h.to_str().ok())
|
.and_then(|h| h.to_str().ok())
|
||||||
.unwrap_or("204");
|
.unwrap_or("204");
|
||||||
let builder = Response::builder()
|
let builder = Response::builder()
|
||||||
.status(StatusCode::OK)
|
|
||||||
.header(header::LOCATION, location)
|
.header(header::LOCATION, location)
|
||||||
.header(header::ETAG, etag);
|
.header(header::ETAG, etag);
|
||||||
match action {
|
match action {
|
||||||
|
@ -248,12 +256,7 @@ pub async fn handle_post_object(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return Ok(resp);
|
Ok(resp)
|
||||||
}
|
|
||||||
|
|
||||||
Err(Error::BadRequest(
|
|
||||||
"Request did not contain a file".to_owned(),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
|
Loading…
Reference in a new issue