Class: FileParam

Inherits:
Object
  • Object
show all
Defined in:
lib/mime_parts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, filename, content) ⇒ FileParam

Returns a new instance of FileParam.



18
19
20
# File 'lib/mime_parts.rb', line 18

def initialize( key, filename, content )
  @key = key; @filename = filename; @content = content
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



17
18
19
# File 'lib/mime_parts.rb', line 17

def content
  @content
end

#filenameObject

Returns the value of attribute filename.



17
18
19
# File 'lib/mime_parts.rb', line 17

def filename
  @filename
end

#keyObject

Returns the value of attribute key.



17
18
19
# File 'lib/mime_parts.rb', line 17

def key
  @key
end

Instance Method Details

#to_multipartObject



22
23
24
25
26
# File 'lib/mime_parts.rb', line 22

def to_multipart
  return "Content-Disposition: form-data; name=\"#{CGI::escape(key)}\"; filename=\"#{filename}\"\r\n" +
"Content-Transfer-Encoding: binary\r\n" +
"Content-type: #{MIME::Types.type_for(filename)}\r\n\r\n" + content + "\r\n"
end