Class: TheCity::API::Request::MultipartWithFile

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

Constant Summary collapse

CONTENT_TYPE =
'Content-Type'

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/the_city/api/request/multipart_with_file.rb', line 9

def call(env)
  for key, value in env[:body]
    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