This is easy:
require 'open-uri'
File.open('/target/path/to/downloaded.file', "wb") do |file|
file.write open('http://example.com/your.file').read
end
Basic Authentication
When your file is protected by HTTP Basic Authentication
, pass your credentials as hash:
File.open('/target/path/to/downloaded.file', "wb") do |file|
file.write open('http://example.com/your.file', :http_basic_authentication => [your_username, your_password]).read
end
Posted by Dominik Schöler to makandra dev (2011-11-05 12:30)