views:

23

answers:

1

In a previous question of mine I got the following answer, which is perfect, but if I want to write my client 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

+1  A: 

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

Anon
Thanks I' ll try it
Antonis