Skip to content

Instantly share code, notes, and snippets.

@smd686s
Forked from scsmith/multipart_em_http.rb
Created October 25, 2012 14:13
Show Gist options
  • Save smd686s/3952777 to your computer and use it in GitHub Desktop.
Save smd686s/3952777 to your computer and use it in GitHub Desktop.
body = MultipartBody.new(:field1 => 'test', :field2 => 'test2')
http = EventMachine::HttpRequest.new('http://example.com').post(
:head => {'content-type' => "multipart/form-data; boundary=#{body.boundary}"},
:body => body.to_s
)
# Or with a file part included
part1 = Part.new('name', 'content', 'file.txt')
part2 = Part.new('name', 'content', 'file.txt')
body = Multipart.new([part1, part2])
http = EventMachine::HttpRequest.new('http://example.com').post(
:head => {'content-type' => "multipart/form-data; boundary=#{body.boundary}"},
:body => body.to_s
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment