Skip to content

Instantly share code, notes, and snippets.

@scsmith
Created January 13, 2011 21:27
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save scsmith/778639 to your computer and use it in GitHub Desktop.
Save scsmith/778639 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
)
@scsmith
Copy link
Author

scsmith commented Jan 13, 2011

The first version didn't use the correct syntax for posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment