Posted about 7 years ago. Visible to the public.

Ruby: Downloading files

This is easy:

Copy
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:

Copy
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

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Dominik Schöler
Last edit:
over 2 years ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more