2021-04-29 21:17:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Middleware
|
|
|
|
class RackMultipartTempfileFactory
|
|
|
|
# Immediately unlink the created temporary file so we don't have to rely
|
|
|
|
# on Rack::TempfileReaper catching this after the fact.
|
|
|
|
FACTORY = lambda do |filename, content_type|
|
|
|
|
Rack::Multipart::Parser::TEMPFILE_FACTORY.call(filename, content_type).tap(&:unlink)
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(app)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
2021-06-08 01:23:25 +05:30
|
|
|
env[Rack::RACK_MULTIPART_TEMPFILE_FACTORY] = FACTORY
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
@app.call(env)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|