cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: ruby & ftp/http file size

From: Stuart Halliday <stuart_at_stuarthalliday.com>
Date: Sat, 27 Jul 2002 12:08:00 +0100

In message <001c01c234e8$dd4a3440$7201a8c0_at_jupiter>
          "Daniel Rubin" <DR2000_at_Akademos.Com> wrote:

> Hello,
>
> Is there a way to get a file size before actually downloading it via http
> and ftp? I'm trying to do this in Ruby, but an example in any other
> language would be helpfull too.

Sure download the headers first.

curl -I http://grin.hq.nasa.gov/IMAGES/MEDIUM/GPN-2000-000058.jpg > file.txt

gives:

HTTP/1.1 200 OK
Accept-Ranges: bytes
Date: Sat, 27 Jul 2002 10:58:14 GMT
Content-Length: 776635
Content-Type: image/jpeg
Server: Apache/1.3.12 (Unix) mod_ssl/2.6.5 OpenSSL/0.9.5a
Last-Modified: Mon, 24 Jul 2000 00:13:24 GMT
ETag: "9b656-bd9bb-397b8a24"
Via: 1.1 cache-6100-edi (NetCache NetApp/5.2.1R1D12)

read off the Content-Length field.

-- 
Stuart Halliday
Webmaster of the Acorn Cybervillage
http://acorn.cybervillage.co.uk/
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-07-27