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

@@ -0,0 +1,20 @@
class Admin::SettingsController < ApplicationController
before_action :require_admin!
def edit
@values = Setting::INTEGERS.keys.index_with { Setting.integer(_1) }
end
def update
submitted = params.fetch(:settings, {}).permit(*Setting::INTEGERS.keys).to_h
records = Setting.update_integers(submitted)
@errors = records.flat_map { _1.errors.full_messages }
if @errors.empty?
Rails.logger.info("[settings] #{current_user.email_address} changed #{submitted.inspect}")
redirect_to edit_admin_settings_path, notice: "Settings saved."
else
@values = Setting::INTEGERS.keys.index_with { Setting.integer(_1) }.merge(submitted)
render :edit, status: :unprocessable_entity
end
end
end
+2 -2
View File
@@ -17,8 +17,8 @@ class DirectUploadsController < ActiveStorage::DirectUploadsController
error =
if !UploadValidation::ALLOWED_CONTENT_TYPES.include?(blob_args[:content_type])
"#{blob_args[:filename]} isn't an allowed file type"
elsif blob_args[:byte_size].to_i > UploadValidation::MAX_SIZE
"#{blob_args[:filename]} is over #{UploadValidation::MAX_SIZE / 1.megabyte} MB"
elsif blob_args[:byte_size].to_i > UploadValidation.max_size
"#{blob_args[:filename]} is over the #{UploadValidation.max_size / 1.megabyte} MB upload limit"
end
render json: { error: error }, status: :unprocessable_entity if error
end