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'
= Hash.new
[:retry] = :any #retry times, :any(any times retry), 0(no retry), or custom numbers(int)
[:resume] = true #true or false, resume continue download, break point resume download
result, error = MDownloader.download(url, path, ) 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
- Fork it ( http://github.com/
/MDowloader/fork ) - Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request