Class: VoiceBase::Request::FilePart
- Defined in:
- lib/voicebase/request/file_part.rb
Instance Attribute Summary collapse
-
#filepath ⇒ Object
Returns the value of attribute filepath.
Attributes inherited from TextPart
Instance Method Summary collapse
-
#initialize(name:, file:) ⇒ FilePart
constructor
A new instance of FilePart.
- #multipart ⇒ Object
Constructor Details
#initialize(name:, file:) ⇒ FilePart
Returns a new instance of FilePart.
9 10 11 12 13 |
# File 'lib/voicebase/request/file_part.rb', line 9 def initialize(name:, file:) @name = name @filepath = file.path @body = file.read end |
Instance Attribute Details
#filepath ⇒ Object
Returns the value of attribute filepath.
7 8 9 |
# File 'lib/voicebase/request/file_part.rb', line 7 def filepath @filepath end |
Instance Method Details
#multipart ⇒ Object
15 16 17 18 |
# File 'lib/voicebase/request/file_part.rb', line 15 def multipart "Content-Disposition: form-data; name=\"#{CGI::escape(name)}\"; filename=\"#{ File.basename(filepath) }\"\r\n" + "Content-Type: #{ mime_type.simplified }\r\n\r\n#{ body }\r\n\r\n" end |