From 4769b17d13951fa054df0200a914136306ce7226 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Wed, 12 Oct 2016 16:48:32 -0700 Subject: [PATCH] Use 'format' in 'raw_upload' example instead of checking Content-Type directly. --- examples/raw_upload/src/main.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/examples/raw_upload/src/main.rs b/examples/raw_upload/src/main.rs index 3363e41e..59e0df52 100644 --- a/examples/raw_upload/src/main.rs +++ b/examples/raw_upload/src/main.rs @@ -5,15 +5,10 @@ extern crate rocket; use rocket::request::Data; use rocket::response::Failure; -use rocket::http::{StatusCode, ContentType}; - -#[post("/upload", data = "")] -fn upload(content_type: ContentType, data: Data) -> Result { - if !content_type.is_text() { - println!(" => Content-Type of upload must be text. Ignoring."); - return Err(Failure(StatusCode::BadRequest)); - } +use rocket::http::StatusCode; +#[post("/upload", format = "text/plain", data = "")] +fn upload(data: Data) -> Result { match data.stream_to_file("/tmp/upload.txt") { Ok(n) => Ok(format!("OK: {} bytes uploaded.", n)), Err(e) => {