开发者

InputStreamBody equivalent in HttpClient 3.x

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜