Module: RouteNGN::HTTP::Multipart
- Defined in:
- lib/routengn/http/multipart.rb
Defined Under Namespace
Constant Summary collapse
- BOUNDARY =
From: http://deftcode.com/code/flickr_upload/multipartpost.rb Helper class to prepare an HTTP POST request with a file upload Mostly taken from http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/113774 WAS: Anything that's broken and wrong probably the fault of Bill Stilwell ([email protected]) NOW: Everything wrong is due to [email protected]
'larrimores-rule0000'- HEADER =
{"Content-type" => "multipart/form-data, boundary=" + BOUNDARY + " "}
Class Method Summary collapse
Class Method Details
.prepare_query(params) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/routengn/http/multipart.rb', line 48 def self.prepare_query(params) fp = [] params.each {|k, v| if v.respond_to?(:read) fp.push(FileParam.new(k, v.path, v.read)) else fp.push(Param.new(k, v)) end } query = fp.collect {|p| "--" + BOUNDARY + "\r\n" + p.to_multipart }.join("") + "--" + BOUNDARY + "--" return query, HEADER end |