开发者

InputStreamBody equivalent in HttpClient 3.x

开发者 https://www.devze.com 2023-01-20 07:39 出处:网络
In a previous question of mine I got the following answer, which is perfect, but if I want to write my c开发者_如何学Golient with HttpClient 3.x, what is the equivalent code?

In a previous question of mine I got the following answer, which is perfect, but if I want to write my c开发者_如何学Golient with HttpClient 3.x, what is the equivalent code? Especially "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"));
// ...

Thanks


The equivalent class is org.apache.commons.httpclient.methods.InputStreamRequestEntity

0

精彩评论

暂无评论...
验证码 换一张
取 消