Hello,
I just wanted to let you know that I've released a new major version of
Down – a Ruby library for file downloads – with a new
HTTP.rb backend (as opposed to the default open-uri + Net::HTTP backend).
For those of you who don't know, the idea behind Down was to have a library for streaming downloads, I created it mainly so that I can use it in
Shrine. Down comes with two main utility methods – `Down.download` and `Down.open`. `Down.download` downloads the remote file to disk in a memory-efficient way, and `Down.open` returns an IO-like object representing the remote file which is downloaded on-demand.
tempfile = Down.download("http://example.org/image.jpg") # downloads the whole file
tempfile.path #=> #<File:/var/folders/k7/6zx6dx6x7ys3rv3srh0nyfj00000gn/T/20170524-56104-c5wpmj.jpg>
io = Down.open("http://example.org/image.jpg") # downloads only the headers
io.read(1024*1024) # downloads and returns the first 1MB
io.read(1024*1024) # downloads and returns the next 1MB
io.rewind
io.read(1024*1024) # returns the first 1MB of cached content
I wanted to take this opportunity to express my gratitude to Tony, Alexey and other maintainers of the HTTP.rb library, I found HTTP.rb to be a breath of fresh air, not just in comparison to Net::HTTP but in comparison to all other HTTP libraries that I've used. Some of the features that really shined when I was implementing the HTTP.rb backend in Down:
- Streaming downloads!
- Correct URI parsing with Addressable::URI
- Chainable HTTP client builder interface
- Ability to retrieve response headers in non-normalized form
- Following redirects with a limit to number of redirects (open-uri can follow but you cannot specify a limit)
Anyway, thank you!
Kind regards,
Janko