No commit activity in last 3 years
No release in over 3 years
Get the file uploading progress.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

net-http-uploadprogress.gem

Get the file uploading progress.

Installation

gem install net-http-uploadprogress

Examples

    require 'net/http/uploadprogress'

    # API style upload
    File.open('path/to.file', 'rb') do |io|
      http = Net::HTTP.new(host, port)
      req = Net::HTTP::Post.new('/')
      req.content_length = io.size
      req.body_stream = io
      Net::HTTP::UploadProgress.new(req) do |progress|
        puts "uploaded so far: #{ progress.upload_size }"
      end
      res = http.request(req)
    end

    # Form input type="file" style upload
    File.open('path/to.file', 'rb') do |io|
      http = Net::HTTP.new(host, port)
      req = Net::HTTP::Post.new('/')
      req.set_form({'file_form_field_name' => io}, 'multipart/form-data')
      Net::HTTP::UploadProgress.new(req) do |progress|
        puts "uploaded so far: #{ progress.upload_size }"
      end
      res = http.request(req)
    end