1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-20 16:35:17 +00:00

Can check if a file is present in the request

This commit is contained in:
2020-06-20 14:06:59 +02:00
parent ca82924b85
commit a02dc8b7fa
3 changed files with 13 additions and 3 deletions

View File

@ -233,5 +233,10 @@ pub fn refresh_single(r: &mut HttpRequestHandler) -> RequestResult {
/// Send a new message
pub fn send_message(r: &mut HttpRequestHandler) -> RequestResult {
if r.has_file("image") {
println!("File is detected.");
}
r.success("implement me")
}

View File

@ -150,12 +150,12 @@ impl FromRequest for CustomRequest {
let mut field = el?;
let content_type = field.content_disposition().ok_or(
ErrorInternalServerError("F1"))?;
ErrorInternalServerError("Missing content type"))?;
let name = content_type.get_name().ok_or(
ErrorInternalServerError("Missing field name!"))?;
// Handle file upload
if content_type.get_filename().is_some() && name.eq("file") {
if content_type.get_filename().is_some() {
let filename = content_type.get_filename().unwrap();
let mut buf = BytesMut::new();