Use modified ActionDispatch::Static to let uploads go through to routes.
This commit is contained in:
parent
eb210f4a18
commit
4310431ee7
2 changed files with 26 additions and 0 deletions
13
config/initializers/static_files.rb
Normal file
13
config/initializers/static_files.rb
Normal 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
|
13
lib/gitlab/middleware/static.rb
Normal file
13
lib/gitlab/middleware/static.rb
Normal 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
|
Loading…
Reference in a new issue