Skip to content

Instantly share code, notes, and snippets.

@rileytg
Created April 18, 2013 19:07
Show Gist options
  • Save rileytg/5415408 to your computer and use it in GitHub Desktop.
Save rileytg/5415408 to your computer and use it in GitHub Desktop.
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