mirror of
https://github.com/actix/examples
synced 2025-06-28 09:50:36 +02:00
Sanitize filename
This commit is contained in:
@ -15,3 +15,4 @@ actix-multipart = "0.2.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
async-std = "1.4.0"
|
||||
sanitize-filename = "0.2"
|
||||
|
@ -12,7 +12,7 @@ async fn save_file(mut payload: Multipart) -> Result<HttpResponse, Error> {
|
||||
let filename = content_type
|
||||
.get_filename()
|
||||
.ok_or_else(|| actix_web::error::ParseError::Incomplete)?;
|
||||
let filepath = format!("./tmp/{}", filename);
|
||||
let filepath = format!("./tmp/{}", sanitize_filename::sanitize(&filename));
|
||||
let mut f = async_std::fs::File::create(filepath).await?;
|
||||
|
||||
// Field in turn is stream of *Bytes* object
|
||||
|
Reference in New Issue
Block a user