[prev in list] [next in list] [prev in thread] [next in thread]
List: httpclient-users
Subject: Re: FileDownload using HttpClient
From: Oleg Kalnichevski <olegk () apache ! org>
Date: 2009-01-20 19:30:37
Message-ID: 4976265D.1080303 () apache ! org
[Download RAW message or body]
arnab_ghosh wrote:
> Hi,
>
> I am using HttpClient for generating a FileDownLoad.
> Let me give a small explanation of the scenario.
>
> I have Webservice which returns me a file as an InputStream. I am using
> Stripes as the Web Framework.
> Here goes the code:
>
> .....Other code
> try {
> HttpClient httpClient = new HttpClient();
> GetMethod getMethod = new GetMethod(assetURL);
> bufferedInputstream = new
> BufferedInputStream(getMethod.getResponseBodyAsStream());
> } catch (Exception e) {
> } finally {
> getMethod.releaseConnection();
> }
> StreamingResolution streamingResolution = new
> StreamingResolution(contentType, bufferedInputstream);
>
> // set the fileName in the StreamingResolution.This in turn sets the
> appropriate response header.
> streamingResolution.setFilename(fileName + "." + extension)
>
> // return the FileInputStream wrapped in the resolution
> return streamingResolution;
>
> The problem I am facing is, If i close the connection in the finally block,
> it throws IOException: Tring to read from an already closed Stream.
>
> So can you tell me when will be the correct time to close the connection?
>
That is what HTTP connection manager is for.
Oleg
What is the correct way for FileDownload via HTTPClient?
>
> Can you help?
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic