Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

use correct max file size in fog hash

Markus Kahlea79fb9a22ce
diff --git a/app/uploaders/direct_fog_uploader.rb b/app/uploaders/direct_fog_uploader.rb
index f4ddd3ac03d..037a3cea8b8 100644
--- a/app/uploaders/direct_fog_uploader.rb
+++ b/app/uploaders/direct_fog_uploader.rb
@@ -18,7 +18,19 @@ class DirectFogUploader < FogFileUploader
uploader
end
- def self.direct_fog_hash(attachment:, success_action_redirect: nil, success_action_status: "201")
+ ##
+ # Generates the direct upload form for the given attachment.
+ #
+ # @param attachment [Attachment] The attachment for which a file is to be uploaded.
+ # @param success_action_redirect [String] URL to redirect to if successful (none by default, using status).
+ # @param success_action_status [String] The HTTP status to return on success (201 by default).
+ # @param max_file_size [Integer] The maximum file size to be allowed in bytes.
+ def self.direct_fog_hash(
+ attachment:,
+ success_action_redirect: nil,
+ success_action_status: "201",
+ max_file_size: Setting.attachment_max_size * 1024
+ )
uploader = for_attachment attachment
if success_action_redirect.present?
@@ -29,7 +41,7 @@ class DirectFogUploader < FogFileUploader
uploader.use_action_status = true
end
- hash = uploader.direct_fog_hash(enforce_utf8: false)
+ hash = uploader.direct_fog_hash(enforce_utf8: false, max_file_size: max_file_size)
if success_action_redirect.present?
hash.merge(success_action_redirect: success_action_redirect)