Class: MIME::Multipart::FormData

Inherits:
MIME::Multipart show all
Defined in:
lib/mime/composite_media.rb

Overview

The FormData subtype expresses values for HTML form data submissions.


RFCs consulted during implementation:

  • RFC-1867 Form-based File Upload in HTML

  • RFC-2388 Returning Values from Forms: multipart/form-data

Instance Attribute Summary

Attributes inherited from CompositeMedia

#boundary

Attributes inherited from MIME::Media

#body, #headers

Attributes included from Headers::MIME

#description, #disposition, #id, #mime_version, #transfer_encoding, #type

Instance Method Summary collapse

Methods inherited from CompositeMedia

#attach, #inline

Methods inherited from MIME::Media

#to_s

Constructor Details

#initializeFormData

Returns a Multipart::FormData object with a content type of multipart/form-data.



180
181
182
# File 'lib/mime/composite_media.rb', line 180

def initialize
  super('form-data')
end

Instance Method Details

#add(entity, name, filename = nil) ⇒ Object

Add the Media object, entity, to the FormData object. name is typically an HTML input tag variable name. If the input tag is of type file, then filename must be specified to indicate a file upload.



189
190
191
192
# File 'lib/mime/composite_media.rb', line 189

def add entity, name, filename = nil
  entity.set_disposition('form-data', 'name' => name, 'filename' => filename)
  super(entity)
end