summaryrefslogtreecommitdiff
path: root/dichroism/src/handlers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dichroism/src/handlers.rs')
-rw-r--r--dichroism/src/handlers.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/dichroism/src/handlers.rs b/dichroism/src/handlers.rs
index 43c11d2..ccaf347 100644
--- a/dichroism/src/handlers.rs
+++ b/dichroism/src/handlers.rs
@@ -106,17 +106,15 @@ async fn post_photo(
) -> Result<HttpResponse, Error> {
let mut responses: Vec<PhotoSetGet> = Vec::new();
- if let Ok(Some(mut field)) = payload.try_next().await {
- // bail if a non-JPEG file was going to be uploaded
- if field.content_type() != &mime::IMAGE_JPEG {
- return Ok(HttpResponse::BadRequest().body("File must be a JPEG image."));
- }
-
+ while let Some(mut field) = payload
+ .try_next()
+ .await
+ .map_err(|e| HttpResponse::BadRequest().body(e.to_string()))?
+ {
// grab all bytes
let mut data: Vec<u8> = Vec::new();
while let Some(chunk) = field.next().await {
- let chunk = chunk?;
- data.extend(chunk);
+ data.extend(chunk?);
}
// create new photo_set