Class: Request::Multipart

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/faraday/multipart.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/faraday/multipart.rb', line 6

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), value.path)
      end
    end
  end

  @app.call(env)
end