MDowloader

简单易用的下载工具,支持断点续传,支持下载进度块回调,失败重试等下载异常,适用于对文件下载稳定性要求高的系统及大文件下载。

Installation

Add this line to your application's Gemfile:

gem 'MDowloader'

And then execute:

$ bundle

Or install it yourself as:

$ gem install MDowloader

Usage

url  = 'http://download.corenetworks.net/50MB-testfile.zip'
path = '~/testfile.zip'

options = Hash.new
options[:retry]  = :any #retry times, :any(any times retry), 0(no retry), or custom numbers(int)
options[:resume] = true #true or false, resume continue download, break point resume download

result, error = MDownloader.download(url, path, options) do |report|
  puts "Progress:#{report[:percent]}  Lave:#{report[:min]}m#{report[:sec]}"
end

if result
  puts 'Download Finished!'
else
  puts 'Download Error!'
  puts error
end

Contributing

  1. Fork it ( http://github.com//MDowloader/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request