Class: Request::MultipartWithFile

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/tigre-client/multipart_with_file.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/tigre-client/multipart_with_file.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