Class: Multipart::MultipartPost

Inherits:
Object
  • Object
show all
Defined in:
lib/spout/helpers/send_file.rb

Constant Summary collapse

BOUNDARY =
"a#41-93r1-^&#213-rule0000"
HEADER =
{ "Content-type" => "multipart/form-data, boundary=#{BOUNDARY} " }

Instance Method Summary collapse

Instance Method Details

#prepare_query(params) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/spout/helpers/send_file.rb', line 89

def prepare_query(params)
  fp = []
  params.each do |k, v|
    if v.respond_to?(:read)
      fp.push(FileParam.new(k, v.path, v.read))
    else
      fp.push(Param.new(k, v))
    end
  end
  query = fp.collect { |p| "--#{BOUNDARY}\r\n" + p.to_multipart }.join("") + "--#{BOUNDARY}--"
  return query, HEADER
end