Using WWW:Mechanize to download a file to disk without loading it all in memory first

What you really want is the Mechanize::Download

http://mechanize.rubyforge.org/Mechanize/Download.html

you can use this way:

require 'mechanize'

agent = Mechanize.new
agent.pluggable_parser.default = Mechanize::Download
agent.get('http://example.com/foo').save('a_file_name')

Leave a Comment