Created
April 18, 2013 19:07
-
-
Save rileytg/5415408 to your computer and use it in GitHub Desktop.
This file contains 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
def download_file(url) | |
uri = URI(url) | |
Rails.logger.info("Downloading evidence #{id} from filepicker.io") | |
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http| | |
request = Net::HTTP::Get.new(uri.path) | |
http.request(request) do |response| | |
file = File.new('evidence') | |
file.binmode | |
response.read_body do |chunk| | |
file.write chunk | |
end | |
file.close | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment