You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by sljm12 <sl...@singnet.com.sg> on 2006/11/13 07:47:47 UTC

Re: retreving file size and file name

Hi thanks for the reply, i am talking abt cases where certain forum software hide the under the URL e.g http://someserver.com/a.php?121 where u can't tell the filename but it redirects to lets say a.jpg.


--- ��ź��� <me...@263.net> wrote:

> Hi 
>   
>    You can read the the Reponse Header("Content-Length") value. its
> repsonse stream length. When you download file, then it's file size.
> 
> The filename is your request filename. For example  i request
> 'http://www.ddf.com/download.exe' then brower would render
> download.exe ...(M)
> 
> ----- Original Message ----- 
> From: "sljm12" <sl...@singnet.com.sg>
> To: <ht...@jakarta.apache.org>
> Sent: Monday, November 13, 2006 2:06 PM
> Subject: retreving file size and file name 
> 
> 
> > Hi all, have 2 questions.
> > 
> > Some background, I am writing a simple downloader that uses
> regular expressions to download files from a forum.
> > 
> > 1. How do i retrieve the file size of the file that i am
> downloading?
> > 
> > 2. The forum uses php, and the link to the files are usually
> something like
> "http://www.insertservername.com/attachment.php?123013" using a web
> browser for downloads the brower is able to know the resultant file
> name, how do i do that in HttpClient?
> > 
> > Pretty new to HttpClient and will appreciate any help.
> > 
> > Regards
> > Stephen
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> httpclient-user-help@jakarta.apache.org
> > 
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: retreving file size and file name

Posted by Roland Weber <RO...@de.ibm.com>.
Hi sljm12,

you can't retrieve the file size. If you're lucky, the server sends
a Content-Length header. Otherwise, there's no way to get it in
advance.

sljm12 <sl...@singnet.com.sg> wrote on 13.11.2006 07:47:47:

> Hi thanks for the reply, i am talking abt cases where certain forum 
> software hide the under the URL e.g http://someserver.com/a.php?121 
> where u can't tell the filename but it redirects to lets say a.jpg.

Disable "follow redirects". Handle the redirect in your application.
Use the last part of the redirect URL as the filename.

hope that helps,
  Roland

> --- Ìì²ÅºüÀê <me...@263.net> wrote:
> 
> > Hi 
> > 
> >    You can read the the Reponse Header("Content-Length") value. its
> > repsonse stream length. When you download file, then it's file size.
> > 
> > The filename is your request filename. For example  i request
> > 'http://www.ddf.com/download.exe' then brower would render
> > download.exe ...(M)
> > 
> > ----- Original Message ----- 
> > From: "sljm12" <sl...@singnet.com.sg>
> > To: <ht...@jakarta.apache.org>
> > Sent: Monday, November 13, 2006 2:06 PM
> > Subject: retreving file size and file name 
> > 
> > 
> > > Hi all, have 2 questions.
> > > 
> > > Some background, I am writing a simple downloader that uses
> > regular expressions to download files from a forum.
> > > 
> > > 1. How do i retrieve the file size of the file that i am
> > downloading?
> > > 
> > > 2. The forum uses php, and the link to the files are usually
> > something like
> > "http://www.insertservername.com/attachment.php?123013" using a web
> > browser for downloads the brower is able to know the resultant file
> > name, how do i do that in HttpClient?
> > > 
> > > Pretty new to HttpClient and will appreciate any help.
> > > 
> > > Regards
> > > Stephen
> > > 
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > httpclient-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> > httpclient-user-help@jakarta.apache.org
> > > 
> > >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org