8个版本 (5个稳定版)
3.0.0 | 2022年11月5日 |
---|---|
2.1.1 | 2022年4月30日 |
2.0.0 | 2022年3月28日 |
2.0.0-beta.1 | 2022年1月27日 |
0.1.1 | 2022年1月15日 |
#1194 在 解析器实现
每月651次下载
在 serv4rs 中使用
55KB
1K SLoC
Actix Easy Multipart
为 actix-web 提供的类型化多部分表单提取器。
示例
use actix_web::Responder;
use actix_easy_multipart::{File, FromMultipart};
use actix_easy_multipart::extractor::MultipartForm;
#[derive(MultipartForm)]
struct Upload {
description: Option<Text<String>>,
timestamp: Text<i64>,
#[multipart(rename="image_set[]")
image_set: Vec<Tempfile>,
}
async fn route(form: MultipartForm<Upload>) -> impl Responder {
format!("Received 5 images: {}", form.image_set.len())
}
功能
- 接收可选字段,使用
Option
。 - 接收 字段列表,使用
Vec<T>
。 - 使用
Text<T>
从纯文本字段反序列化整数、浮点数和枚举。 - 使用
Json<T>
从JSON上传反序列化复杂数据。 - 使用
Tempfile
将文件上传接收到的文件存储到磁盘上的临时文件中。 - 用户自定义的异步字段读取器,例如,您可能希望将表单数据流式传输到对象存储服务,只需实现
FieldReader
特性。
版本和兼容性
actix-easy-multipart | actix-web | tokio |
---|---|---|
0.x | 2.x | 0.2 |
1.x | 3.x | 0.2 |
2.x | 4.x | 1 |
3.x | 4.x | 1 |
另请参阅
依赖项
~17–29MB
~549K SLoC