This commit is contained in:
@@ -31,11 +31,11 @@ pub async fn upload_file(MultipartForm(mut form): MultipartForm<UploadIsoForm>)
|
||||
return Ok(HttpResponse::BadRequest().json("File is too large!"));
|
||||
}
|
||||
|
||||
if let Some(m) = &file.content_type {
|
||||
if !constants::ALLOWED_ISO_MIME_TYPES.contains(&m.to_string().as_str()) {
|
||||
log::error!("Uploaded ISO file has an invalid mimetype!");
|
||||
return Ok(HttpResponse::BadRequest().json("Invalid mimetype!"));
|
||||
}
|
||||
if let Some(m) = &file.content_type
|
||||
&& !constants::ALLOWED_ISO_MIME_TYPES.contains(&m.to_string().as_str())
|
||||
{
|
||||
log::error!("Uploaded ISO file has an invalid mimetype!");
|
||||
return Ok(HttpResponse::BadRequest().json("Invalid mimetype!"));
|
||||
}
|
||||
|
||||
let file_name = match &file.file_name {
|
||||
@@ -87,16 +87,16 @@ pub async fn upload_from_url(req: web::Json<DownloadFromURLReq>) -> HttpResult {
|
||||
|
||||
let response = reqwest::get(&req.url).await?;
|
||||
|
||||
if let Some(len) = response.content_length() {
|
||||
if len > constants::ISO_MAX_SIZE.as_bytes() as u64 {
|
||||
return Ok(HttpResponse::BadRequest().json("File is too large!"));
|
||||
}
|
||||
if let Some(len) = response.content_length()
|
||||
&& len > constants::ISO_MAX_SIZE.as_bytes() as u64
|
||||
{
|
||||
return Ok(HttpResponse::BadRequest().json("File is too large!"));
|
||||
}
|
||||
|
||||
if let Some(ct) = response.headers().get("content-type") {
|
||||
if !constants::ALLOWED_ISO_MIME_TYPES.contains(&ct.to_str()?) {
|
||||
return Ok(HttpResponse::BadRequest().json("Invalid file mimetype!"));
|
||||
}
|
||||
if let Some(ct) = response.headers().get("content-type")
|
||||
&& !constants::ALLOWED_ISO_MIME_TYPES.contains(&ct.to_str()?)
|
||||
{
|
||||
return Ok(HttpResponse::BadRequest().json("Invalid file mimetype!"));
|
||||
}
|
||||
|
||||
let mut stream = response.bytes_stream();
|
||||
|
Reference in New Issue
Block a user