I am trying to execute a POST file using HttpClient. However, I do not have access to the actual File, but I have access to it InputStream. Is there a way I can still send the file?
This is what I have done so far:
public void sendFile (InputStream instream) {
HttpClient client = new HttpClient();
PostMethod method = new PostMethod("http://localhost:8080/myservice/testupload");
Part[] parts = new Part[] {
};
method.setRequestEntity(
new MultipartRequestEntity(parts, method.getParams()));
client.executeMethod(method);
}
as you can see, the file is FilePartneeded, but I have it InputStream. How can I post the input stream as a file?
birdy source
share