You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@wink.apache.org by srinivasan venkat <sr...@yahoo.com> on 2011/04/01 11:35:32 UTC
Extracting BufferedOutMultiPart object in Client side using HttpClient or RestClient.
Hi,
We are wrapping an String,FileInputStream in to OutPart body object separated by simple boundaries and wrapping this multiple OutPart objects in to BufferedOutMultiPart .We are Setting this BufferedOutMultiPart in to the response.entity object in our server side.
>From the client side we need to extract this FileInputStream which is wrapped inside BufferedOutMultiPart using org.apache.commons.httpclient.*; or RESTClient
How we can achieve this using httpclient or RestClient from response.entity object in the client side?
Need help in this regard.
Re: Extracting BufferedOutMultiPart object in Client side using HttpClient or RestClient.
Posted by srinivasan venkat <sr...@yahoo.com>.
I can directly do this in my resource class level as below,
First part is my String Object and my second part is my FileInputStream.
public void extractResponse(BufferedOutMultiPart bufferedOutMultiPart) {
Iterator iter = bufferedOutMultiPart.getIterator();
int ch;
FileInputStream fin = null;
FileOutputStream out = null;
try {
out = new FileOutputStream("D:\\file123.pdf");
while (iter.hasNext()) {
OutPart op = (OutPart) iter.next();
op = (OutPart) iter.next();
fin = (FileInputStream) op.getBody();
while ((ch = fin.read()) != -1) {
out.write((char) ch);
}
fin.close();
}
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
But I need to extract this in my client side using httpclient from response.entity or by RestClient where i set BufferedOutMultiPart in to the response.entity in my server side.