Class: Gitlab::Middleware::RackMultipartTempfileFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/middleware/rack_multipart_tempfile_factory.rb

Constant Summary collapse

FACTORY =

Immediately unlink the created temporary file so we don't have to rely on Rack::TempfileReaper catching this after the fact.

lambda do |filename, content_type|
  Rack::Multipart::Parser::TEMPFILE_FACTORY.call(filename, content_type).tap(&:unlink)
end

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RackMultipartTempfileFactory

Returns a new instance of RackMultipartTempfileFactory.


12
13
14
# File 'lib/gitlab/middleware/rack_multipart_tempfile_factory.rb', line 12

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object


16
17
18
19
20
# File 'lib/gitlab/middleware/rack_multipart_tempfile_factory.rb', line 16

def call(env)
  env[Rack::RACK_MULTIPART_TEMPFILE_FACTORY] = FACTORY

  @app.call(env)
end