1
0
mirror of https://github.com/actix/examples synced 2025-06-29 10:14:58 +02:00
This commit is contained in:
cheolgyu
2020-02-06 10:06:41 +09:00
parent 5fb3d3270e
commit c6b75d5006
5 changed files with 40 additions and 16 deletions

View File

@ -77,20 +77,24 @@ pub async fn split_payload(payload: &mut Multipart) -> (bytes::Bytes, Vec<Tmpfil
data = chunk.expect(" split_payload err chunk");
}
} else {
if content_type.get_filename() != None {
let filename = content_type.get_filename().unwrap();
let tmp_file = Tmpfile::new(filename);
let tmp_path = tmp_file.tmp_path.clone();
let mut f = web::block(move || std::fs::File::create(&tmp_path))
.await
.unwrap();
while let Some(chunk) = field.next().await {
let data = chunk.unwrap();
f = web::block(move || f.write_all(&data).map(|_| f))
match content_type.get_filename() {
Some(filename) => {
let tmp_file = Tmpfile::new(filename);
let tmp_path = tmp_file.tmp_path.clone();
let mut f = web::block(move || std::fs::File::create(&tmp_path))
.await
.unwrap();
while let Some(chunk) = field.next().await {
let data = chunk.unwrap();
f = web::block(move || f.write_all(&data).map(|_| f))
.await
.unwrap();
}
tmp_files.push(tmp_file.clone());
}
None => {
println!("file none");
}
tmp_files.push(tmp_file.clone());
}
}
}