Skip to content
A ruby library to create multipart bodies. At the moment it is only creating form-data but this needs to be expanded.
Pull request Compare This branch is 4 commits behind CloudMailin:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


The multipart body is an attempt to bring consistency to multipart content in Ruby. When developing CloudMailin we struggled to find a gem to help us create multipart bodies. Many different libraries had implemented multipart bodies through their own implementation but non could be used independently.

The aim of MultipartBody is to ensure consistency when creating (and parsing in future) multipart content


require 'multipart_body'

# From a hash
multipart = => 'content', :field2 => 'something else')

# With parts
part = => 'name', :body => 'body', :filename => 'f.txt', :content_type => 'text/plain', :encoding => :base64)

# or to specify just the name, body and optional filename
part ='name', 'content', 'file.txt')
multipart =[part])

# Output
part.to_s #=> The part with headers and content
multipart.to_s #=> The full list of parts joined by boundaries


  • Implement Parsing
  • Add different encodings
  • Add the ability to automatically add files and have the filename set


Copyright 2010 by Steve Smith (CloudMailin) and is released under the MIT license.

Something went wrong with that request. Please try again.