From: Rajinder Yadav Date: 2010-12-21T03:30:59+09:00 Subject: Re: downloading a file On Mon, Dec 20, 2010 at 1:19 PM, Rajinder Yadav wrote: > On Mon, Dec 20, 2010 at 1:10 PM, Brian Candler wrote: >> Rajinder Yadav wrote in post #969592: >>>> Use wget [-c] >>> >>> ruby has a wget command? i want to do this from ruby code, and with no >>> backquote either >> >> I was thinking of: >> >>    system("wget ....") >> >> If you don't have wget on your system, I'm afraid I don't know of an >> existing Ruby library which does download-to-file with restarting of >> partial transfers. >> >> You can cobble something together using Net::HTTP, but to do the >> restarts you'll have to use the set_range method to add the Range: >> header - see RFC 2616 section 14.35. >> >> Note that old HTTP servers may ignore the Range: header, so you should >> check that the response content_range is what you asked for. > > well if i just want to download a file, is there something i can use > that is simple? > > i tired using open-uri, but when i read and then save the file it mess > up the file? something like this > > require 'open-uri' > url = 'http://www.openssl.org/source/openssl-1.0.0c.tar.gz' > file = open(url) > c = file.read > > f = File.open('openssl-1.0.0c.tar.gz', 'w') > f.write c > f.close > i'm wondering if there is libcurl solution out there that will download files, both binary and text? -- Kind Regards, Rajinder Yadav | DevMentor.org | Do Good! ~ Share Freely GNU/Linux: 2.6.35-22-generic Kubuntu x86_64 10.10 | KDE 4.5.1 Ruby 1.9.2p0 | Rails 3.0.1