RE: Get file size without downloading
usef wrote: Hi, Is there any way to get the size of a file without downloading it? I want to write a program using LWP to download a file only if it is bigger than 3K but smaller than 500K. So I need to know the file size in the first place. You issue a HEAD request to the server and look at the Content-Length response header. You can use the LWP::Simple module's head method to get this information easily. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Get file size without downloading
Hi, FTP or HTTP? HTTP, but I want to know the method for FTP as well. Thanks -u PS. Sorry Rus for multiple copy *smacks forehead* -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Get file size without downloading
usef wrote: Hi, FTP or HTTP? HTTP, but I want to know the method for FTP as well. Thanks -u I think that will work for FTP as well. Give it a try. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Get file size without downloading
On Wed, 10 Dec 2003, usef wrote: Hi, Is there any way to get the size of a file without downloading it? I want to write a program using LWP to download a file only if it is bigger than 3K but smaller than 500K. So I need to know the file size in the first place. Hi, FTP or HTTP? Rgds Rus -- e: [EMAIL PROTECTED] | Linux + FreeBSD Servers from $12.50/mo e: [EMAIL PROTECTED] | Full Root Access m: +44 7919 373537 | Free Trial Account t: 1-888-327-6330 | http://www.jvds.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Get file size without downloading
Hello, usef [EMAIL PROTECTED] asked: Is there any way to get the size of a file without downloading it? I want to write a program using LWP to download a file only if it is bigger than 3K but smaller than 500K. So I need to know the file size in the first place. Try making a HEAD request - that should return file size and last modification date. This obviously will not work for CGI URLs. HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Get file size without downloading
Is there any way to get the size of a file without downloading it? I want to write a program using LWP to download a file only if it is bigger than 3K but smaller than 500K. So I need to know the file size in the first place. Try making a HEAD request - that should return file size and last modification date. This obviously will not work for CGI URLs. Something like: my $ua = LWP::UserAgent-new(); my $result = $ua-head($url); my $remote_headers = $result-headers; $total_size = $remote_headers-content_length; -- Morbus Iff ( i put the demon back in codemonkey ) Culture: http://www.disobey.com/ and http://www.gamegrene.com/ My book, Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/ icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Get file size without downloading
On Wed, 2003-12-10 at 09:42, Bob Showalter wrote: usef wrote: Hi, FTP or HTTP? HTTP, but I want to know the method for FTP as well. Thanks -u I think that will work for FTP as well. Give it a try. If I type ls when I FTP into somewhere I get a listing of files and size. I would guess either: a) ls is a command in FTP b) there is a corresponding command in the FTP module you are using. -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Get file size without downloading
Dan Anderson [EMAIL PROTECTED] wrote: On Wed, 2003-12-10 at 09:42, Bob Showalter wrote: usef wrote: Hi, FTP or HTTP? HTTP, but I want to know the method for FTP as well. Thanks -u I think that will work for FTP as well. Give it a try. If I type ls when I FTP into somewhere I get a listing of files and size. I would guess either: a) ls is a command in FTP b) there is a corresponding command in the FTP module you are using. In standard ftp, you can do 'size'. The Net::FTP for perl has a corresponding command also. When you are in standard ftp, just type ftp size yourFile and it will return something like ftp size yourFile 213 12523 where 213 is the message number and (in my case) 12523 is the size of the file. -Jeff __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response