class RackCustomTmpdir

Constants

BASENAME_PREFIX
VERSION

Public Class Methods

new(app, tmpdir = nil) click to toggle source
# File lib/rack_custom_tmpdir.rb, line 6
def initialize(app, tmpdir = nil)
  @app = app

  @tempfile_factory = lambda do |filename, content_type|
    basename_suffix = ::File.extname(filename.gsub("\0".freeze, '%00'.freeze))
    Tempfile.new([BASENAME_PREFIX, basename_suffix], tmpdir)
  end
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack_custom_tmpdir.rb, line 15
def call(env)
  env[Rack::RACK_MULTIPART_TEMPFILE_FACTORY] = @tempfile_factory
  @app.call(env)
end