【问题标题】:How to POST a multipart form using async version of reqwest crate?如何使用异步版本的 reqwest crate 发布多部分表单?
【发布时间】:2022-02-01 20:09:57
【问题描述】:

https://docs.rs/reqwest/latest/reqwest/blocking/multipart/struct.Form.html 的文档显示了从文件创建 multipart::Form 的示例。

    let file = reqwest::blocking::multipart::Form::new().file("key", "/path/to/file")?;

    let response = reqwest::blocking::Client::new()
        .post("https:://test.com.br/send")
        .multipart(file)
        .send()
        .unwrap();

但函数“.file”仅在reqwest的阻塞版本上可用(reqwest::blocking::multipart::Form)。

我已经测试了阻止版本,并且能够发送表单。但是我找不到使用异步版本(reqwest::multipart::Form)的方法。

是否有其他方法可以使用异步版本进行此调用?

【问题讨论】:

标签: asynchronous rust multipart reqwest


【解决方案1】:

如果您只想使用异步发布文件,请查看this answer。如果要构建多部分表单,请尝试使用reqwest::multipart::Part 构建主体,同时将文件包装到流中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-13
    • 1970-01-01
    • 2015-10-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多