How to download a file?

To follow up on the excellent suggestion by Kenosis :wink: Here is how
Rio's copy-to operator could be used to download a file.

require 'rio'

rio(url) > rio('output_dir')

The post mentions that the file is compressed. If it is a gzipped file
and one wished to have an uncompressed local copy, something like the
following could be used.

rio(url_of_gzipped_file).gzip > rio('output_dir')

Cheers
-Christopher

Kenosis wrote:

···

Might also be a good use of Rio (search this group for info on Rio.)

Ken

Jeffrey Schwab wrote:
> Une bévue wrote:
> > i'd like to know how to download a compressed file (4 to 15 mb) with
> > ruby, and how to choose the folder to receive it ???
>
> require 'open-uri'
>
> url = 'http://groups.google.com/group/comp.lang.ruby/tree/browse_frm/' +
> 'thread/6db927bc86697398/f3cd16a2b541528c?rnum=1&_done=' +
> '%2Fgroup%2Fcomp.lang.ruby%2Fbrowse_frm%2Fthread%2F6db9' +
> '27bc86697398%2Ff3cd16a2b541528c%3F#doc_f3cd16a2b541528c'
>
> open("myfile.html", 'w') do |dst|
> open(url) do |src|
> dst.write(src.read)
> end
> end