Class: Request::MultipartWithFile

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/faraday/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
# File 'lib/faraday/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), value.path)
      end
    end
  end

  @app.call(env)
end