Skip to content

Instantly share code, notes, and snippets.

@hanshasselberg
Created May 12, 2013 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanshasselberg/5565206 to your computer and use it in GitHub Desktop.
Save hanshasselberg/5565206 to your computer and use it in GitHub Desktop.
Demonstrate file upload with ethon.
require 'ethon'
def forge_easy(url, file)
easy = Ethon::Easy.new(url: url, upload: true)
easy.set_read_callback(file)
easy.infilesize = file.size
easy
end
multi = Ethon::Multi.new
multi.add(forge_easy("www.example.com", File.open(__FILE__)))
multi.perform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment