Skip to content

Instantly share code, notes, and snippets.

@johanb
Created March 18, 2012 19:35
Show Gist options
  • Select an option

  • Save johanb/2080126 to your computer and use it in GitHub Desktop.

Select an option

Save johanb/2080126 to your computer and use it in GitHub Desktop.
Stream httpndownload straight to disk.
Net::HTTP.start("someurl_without_the_protocol.com") do |http|
begin
file = open("/path/to/file.mov", 'wb')
http.request_get('/' + URI.encode("file.mov")) do |response|
response.read_body do |segment|
file.write(segment)
end
end
ensure
file.close
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment