Skip to content

Instantly share code, notes, and snippets.

@rileytg
Created Apr 18, 2013
Embed
What would you like to do?
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