How do I HTTP post stream data from memory in Ruby?
问题 I would like to upload data I generated at runtime in Ruby, something like feeding the upload from a block. All examples I found only show how to stream a file that must be on disk prior to the request but I do not want to buffer the file. What is the best solution besides rolling my own socket connection? This a pseudocode example: post_stream('127.0.0.1', '/stream/') do |body| generate_xml do |segment| body << segment end end 回答1: Code that works. require 'thread' require 'net/http' require