How to perform a file upload (multipart post) with Ruby
You have at least 5 options:
- Stanislav Vitvitskiy's solution
- RestClient
require 'rest_client'
RestClient.post 'http://localhost:3000/foo', fields_hash.merge(:file => File.new('/path/to/file'))
- The curb gem
- The multipart-post Net:HTTP extension
- Calling curl from Ruby with, for example, Open3.
Open3.popen3('curl <and your parameters>') do |input, output, error|
# do something
end