Support for PostObject #222
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 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) {
|
||||
name
|
||||
} 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
|
||||
let key = params
|
||||
|
@ -235,7 +244,6 @@ pub async fn handle_post_object(
|
|||
.and_then(|h| h.to_str().ok())
|
||||
.unwrap_or("204");
|
||||
let builder = Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
.header(header::LOCATION, location)
|
||||
.header(header::ETAG, etag);
|
||||
match action {
|
||||
|
@ -248,12 +256,7 @@ pub async fn handle_post_object(
|
|||
}
|
||||
};
|
||||
|
||||
return Ok(resp);
|
||||
}
|
||||
|
||||
Err(Error::BadRequest(
|
||||
"Request did not contain a file".to_owned(),
|
||||
))
|
||||
Ok(resp)
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
|
Loading…
Reference in a new issue