Skip to content

A platform for community discussion. Free, open, simple.

DEV: allow plugins to override max file size for avatar downloads (#16970)

Jeff Wong2dd09b4b6a71
diff --git a/app/controllers/user_avatars_controller.rb b/app/controllers/user_avatars_controller.rb
index cc28143c0db..3f148cb477a 100644
--- a/app/controllers/user_avatars_controller.rb
+++ b/app/controllers/user_avatars_controller.rb
@@ -142,6 +142,11 @@ class UserAvatarsController < ApplicationController
render_blank
end
+ # Allow plugins to overwrite max file size value
+ def max_file_size
+ 1.megabyte
+ end
+
PROXY_PATH = Rails.root + "tmp/avatar_proxy"
def proxy_avatar(url, last_modified)
@@ -157,7 +162,7 @@ class UserAvatarsController < ApplicationController
FileUtils.mkdir_p PROXY_PATH
tmp = FileHelper.download(
url,
- max_file_size: 1.megabyte,
+ max_file_size: max_file_size,
tmp_file_name: filename,
follow_redirect: true,
read_timeout: 10