Class: Twitter::Request::MultipartWithFile
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Twitter::Request::MultipartWithFile
- Defined in:
- lib/twitter/request/multipart_with_file.rb
Constant Summary collapse
- CONTENT_TYPE =
'Content-Type'.freeze
Class Attribute Summary collapse
-
.mime_type ⇒ Object
Returns the value of attribute mime_type.
Instance Method Summary collapse
Class Attribute Details
.mime_type ⇒ Object
Returns the value of attribute mime_type.
8 9 10 |
# File 'lib/twitter/request/multipart_with_file.rb', line 8 def mime_type @mime_type end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/twitter/request/multipart_with_file.rb', line 12 def call(env) if env[:body].is_a?(Hash) env[:body].each do |key, value| if value.respond_to?(:to_io) env[:body][key] = Faraday::UploadIO.new(value, mime_type(value.path), value.path) env[:request_headers][CONTENT_TYPE] = self.class.mime_type end end end @app.call(env) end |