Last active
August 29, 2015 14:06
-
-
Save adeelejaz/3d428acb425b7a0153ed to your computer and use it in GitHub Desktop.
How to download a bunch of files in Rails and save them?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
arr = ['http://example.com/file1.txt', 'http://example.com/file2.txt'] | |
arr.each do |url| | |
open(url.split('/').last, 'wb') do |file| | |
file << open(url).read | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment