gpt4 book ai didi

java - HttpClient 3.x 中的 InputStreamBody 等效项

转载 作者:行者123 更新时间:2023-12-01 16:01:01 31 4
gpt4 key购买 nike

在我之前的一个问题中,我得到了以下答案,这是完美的,但如果我想用 HttpClient 3.x 编写客户端,等效代码是什么?特别是“InputStreamBody(new FileInputStream(file)”?

Just add different multipart parts with same file content but a different part and filename. With InputStreamBody you can specify a different filename for each part. E.g.

MultipartEntity entity = new MultipartEntity();
entity.addPart("file1", new InputStreamBody(new FileInputStream(file), "name1.ext"));
entity.addPart("file2", new InputStreamBody(new FileInputStream(file), "name2.ext"));
entity.addPart("file3", new InputStreamBody(new FileInputStream(file), "name3.ext"));
// ...

谢谢

最佳答案

等效类是org.apache.commons.httpclient.methods.InputStreamRequestEntity

关于java - HttpClient 3.x 中的 InputStreamBody 等效项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3926391/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com