Class: Multipart::FileParam
- Inherits:
-
Object
- Object
- Multipart::FileParam
- Defined in:
- lib/multipart/post.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#k ⇒ Object
Returns the value of attribute k.
Instance Method Summary collapse
-
#initialize(k, filename, content) ⇒ FileParam
constructor
A new instance of FileParam.
- #to_multipart ⇒ Object
Constructor Details
#initialize(k, filename, content) ⇒ FileParam
Returns a new instance of FileParam.
64 65 66 67 68 |
# File 'lib/multipart/post.rb', line 64 def initialize(k, filename, content) @k = k @filename = filename @content = content end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
62 63 64 |
# File 'lib/multipart/post.rb', line 62 def content @content end |
#filename ⇒ Object
Returns the value of attribute filename.
62 63 64 |
# File 'lib/multipart/post.rb', line 62 def filename @filename end |
#k ⇒ Object
Returns the value of attribute k.
62 63 64 |
# File 'lib/multipart/post.rb', line 62 def k @k end |
Instance Method Details
#to_multipart ⇒ Object
70 71 72 73 74 |
# File 'lib/multipart/post.rb', line 70 def to_multipart mime_type = MIME::Types.type_for(filename)[0] || MIME::Types["application/octet-stream"][0] return "Content-Disposition: form-data; name=\"#{URI::encode(k)}\"; filename=\"#{ filename }\"\r\n" + "Content-Type: #{ mime_type.simplified }\r\n\r\n#{ content }\r\n" end |