mirror of
https://github.com/actix/examples
synced 2025-06-29 10:14:58 +02:00
example
This commit is contained in:
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user