Class: Echowrap::Request::MultipartWithFile

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/echowrap/request/multipart_with_file.rb

Constant Summary collapse

CONTENT_TYPE =
'Content-Type'

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/echowrap/request/multipart_with_file.rb', line 8

def call(env)
  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)
    end
  end if env[:body].is_a?(::Hash)
  @app.call(env)
end