Skip to content

Instantly share code, notes, and snippets.

@notblizzard
Created December 27, 2015 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notblizzard/ad92f2c0320f879f202a to your computer and use it in GitHub Desktop.
Save notblizzard/ad92f2c0320f879f202a to your computer and use it in GitHub Desktop.
require 'zlib'
require 'open-uri'
file_name = "hello.tar.gz"
download_url = "https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.8.tar.gz"
File.open(file_name, "wb") do |f|
f.write(Zlib::GzipReader.new(open(download_url)).read)
end
File.open(file_name, "r") do |f|
g = Zlib::GzipReader.open(f)
puts g.read
g.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment