Class: Rack::RawUpload

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/raw_upload.rb

Constant Summary collapse

VERSION =
'1.1.1'

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}) ⇒ RawUpload

Returns a new instance of RawUpload.



9
10
11
12
13
14
15
# File 'lib/rack/raw_upload.rb', line 9

def initialize(app, opts = {})
  @app = app
  @paths = opts[:paths]
  @explicit = opts[:explicit]
  @tmpdir = opts[:tmpdir] || Dir::tmpdir
  @paths = [@paths] if @paths.kind_of?(String)
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
# File 'lib/rack/raw_upload.rb', line 17

def call(env)
  kick_in?(env) ? convert_and_pass_on(env) : @app.call(env)
end

#upload_path?(request_path) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/rack/raw_upload.rb', line 21

def upload_path?(request_path)
  return true if @paths.nil?

  @paths.any? do |candidate|
    literal_path_match?(request_path, candidate) || wildcard_path_match?(request_path, candidate)
  end
end