Class: Twitter::Request::MultipartWithFile
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Twitter::Request::MultipartWithFile
- Defined in:
- lib/twitter/request/multipart_with_file.rb
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/twitter/request/multipart_with_file.rb', line 7 def call(env) if env[:body].is_a?(Hash) env[:body].each do |key, value| if value.is_a?(File) env[:body][key] = Faraday::UploadIO.new(value, mime_type(value.path), value.path) elsif value.is_a?(Hash) && (value['io'].is_a?(IO) || value['io'].is_a?(StringIO)) env[:body][key] = Faraday::UploadIO.new(value['io'], mime_type('.'+value['type']), '') end end end @app.call(env) end |