Sha256: 7ba4711c75a391492e1dfc65ddb12866ecd0b2b47e56e23e80f91c8608c80ac6

Contents?: true

Size: 535 Bytes

Versions: 12

Compression:

Stored size: 535 Bytes

Contents

dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'httparty')
require 'pp'

# download file linux-4.6.4.tar.xz without using the memory
response = nil
filename = "linux-4.6.4.tar.xz"
url = "https://cdn.kernel.org/pub/linux/kernel/v4.x/#{filename}"

File.open(filename, "w") do |file|
  response = HTTParty.get(url, stream_body: true) do |fragment|
    print "."
    file.write(fragment)
  end
end
puts

pp "Success: #{response.success?}"
pp File.stat(filename).inspect
File.unlink(filename)

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
httparty-0.16.3 examples/stream_download.rb
httparty-0.16.2 examples/stream_download.rb
httparty-0.16.1 examples/stream_download.rb
httparty-0.16.0 examples/stream_download.rb
httparty-0.15.7 examples/stream_download.rb
httparty-0.15.6 examples/stream_download.rb
httparty-0.15.5 examples/stream_download.rb
httparty-0.15.4 examples/stream_download.rb
httparty-0.15.3 examples/stream_download.rb
httparty-0.15.2 examples/stream_download.rb
httparty-0.15.1 examples/stream_download.rb
httparty-0.15.0 examples/stream_download.rb