reqwest v0.9.18 的文档展示了一个上传文件的例子:
let file = fs::File::open("from_a_file.txt")?;
let client = reqwest::Client::new();
let res = client.post("http://httpbin.org/post")
.body(file)
.send()?;
reqwest v0.11 的最新文档不再包含此示例,当调用 body()
时尝试构建会失败,并出现以下错误:
the trait `From<std::fs::File>` is not implemented for `Body`
如何更新发送文件的方法?