Admin setting for the maximum upload size

- Admin -> Settings: maximum upload size per file (1-1024 MB, default 50),
  stored in a new settings table and read on each use, so a change applies
  to every process at once
- Enforced by attachment validation and the direct-upload endpoint; upload
  forms, bulk upload and Admin -> About show the current limit
- .sam.zip import accepts files up to 1 GB to match

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-07 09:45:12 -05:00
1 parent 4f548f3874
commit ef7cd2efba
16 files changed
+186 -13

No files matched your search

+5 -2
View File
@@ -7,7 +7,9 @@ module UploadValidation
application/pdf text/plain application/gpx+xml application/xml text/xml
text/csv application/vnd.google-earth.kml+xml application/octet-stream
].freeze
MAX_SIZE = 50.megabytes
# Set by admins (Admin → Settings), default 50 MB.
def self.max_size = Setting.max_upload_bytes
class_methods do
def validates_uploads(*names)
@@ -18,7 +20,8 @@ module UploadValidation
unless ALLOWED_CONTENT_TYPES.include?(att.blob.content_type)
errors.add(name, "#{att.filename} is not an allowed file type")
end
errors.add(name, "#{att.filename} is too large") if att.blob.byte_size > MAX_SIZE
limit = UploadValidation.max_size
errors.add(name, "#{att.filename} is over the #{limit / 1.megabyte} MB upload limit") if att.blob.byte_size > limit
end
end
end