Use modified ActionDispatch::Static to let uploads go through to routes.

This commit is contained in:
Douwe Maan 2015-02-20 12:44:07 +01:00
parent eb210f4a18
commit 4310431ee7
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,13 @@
begin
app = Rails.application
app.config.middleware.swap(
ActionDispatch::Static,
Gitlab::Middleware::Static,
app.paths["public"].first,
app.config.static_cache_control
)
rescue
# If ActionDispatch::Static wasn't loaded onto the stack (like in production),
# an exception is raised.
end

View file

@ -0,0 +1,13 @@
module Gitlab
module Middleware
class Static < ActionDispatch::Static
UPLOADS_REGEX = /\A\/uploads(\/|\z)/.freeze
def call(env)
return @app.call(env) if env['PATH_INFO'] =~ UPLOADS_REGEX
super
end
end
end
end