summaryrefslogtreecommitdiff
path: root/dichroism/src/handlers.rs
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-11-04 08:59:41 -0500
committerAdam T. Carpenter <atc@53hor.net>2020-11-04 08:59:41 -0500
commit76ad709e0afed734c4331ddb8de91745a541a67d (patch)
treebe7b3d20387506ed23fa9c4f4f386ef3bbb1ae86 /dichroism/src/handlers.rs
parentdcc96d0b349583e5d6a0f25ae1f7a3ffa3769788 (diff)
downloadtheglassyladies-76ad709e0afed734c4331ddb8de91745a541a67d.tar.xz
theglassyladies-76ad709e0afed734c4331ddb8de91745a541a67d.zip
basic photo upload working completely
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