Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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

About

Get the file uploading progress for Ruby.

Resources

Releases

No releases published

Packages

No packages published

Languages