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.



176
177
178
# File 'lib/mime/composite_media.rb', line 176

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.



185
186
187
188
# File 'lib/mime/composite_media.rb', line 185

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