Project

General

Profile

Feature #18556 » 0001-Raise-the-maximum-number-of-files-that-can-be-attach.patch

Go MAEDA, 2026-09-24 12:58

View differences:

app/assets/javascripts/attachments.js
var attachmentsFields = attachmentsForm.find('.attachments_fields');
var attachmentsIcons = attachmentsForm.find('.attachments_icons');
var addAttachment = attachmentsForm.find('.add_attachment');
var maxFiles = ($(inputEl).attr('multiple') == 'multiple' ? 10 : 1);
var maxFiles = $(inputEl).data('max-number-of-files');
var delIcon = attachmentsIcons.find('svg.svg-del').clone();
var attachmentIcon = attachmentsIcons.find('svg.svg-attachment').clone();
......
$.each(files, function() {addFile(inputEl, this, true);});
}
if (filesLength > ($(inputEl).attr('multiple') == 'multiple' ? 10 : 1)) {
if (filesLength > $(inputEl).data('max-number-of-files')) {
window.alert($(inputEl).data('max-number-of-files-message'));
}
return sizeExceeded;
app/views/attachments/_form.html.erb
<% saved_attachments ||= container.saved_attachments if defined?(container) && container %>
<% multiple = true unless defined?(multiple) && multiple == false %>
<% show_add = multiple || saved_attachments.blank? %>
<% max_number_of_files = multiple ? Redmine::Configuration['max_attachments_at_once'].to_i : 1 %>
<% description = (defined?(description) && description == false ? false : true) %>
<% css_class = (defined?(filedrop) && filedrop == false ? '' : (attachment_format_custom_field ? 'custom-field-filedrop' : 'filedrop')) %>
......
:multiple => multiple,
:onchange => 'addInputFiles(this);',
:data => {
:max_number_of_files_message => l(:error_attachments_too_many, :max_number_of_files => (multiple ? 10 : 1)),
:max_number_of_files => max_number_of_files,
:max_number_of_files_message => l(:error_attachments_too_many, :max_number_of_files => max_number_of_files),
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
config/configuration.yml.example
# Maximum number of simultaneous AJAX uploads
#max_concurrent_ajax_uploads: 2
# Maximum number of files that can be attached at once with the
# attachment form
#
# This limit is only applied in the browser, to keep the form usable when
# many files are dropped by mistake. The number of attachments is not
# limited by the server nor by the REST API.
#max_attachments_at_once: 50
# URL of the avatar server
#
# By default, Redmine uses Gravatar as the avatar server for displaying
lib/redmine/configuration.rb
'avatar_server_url' => 'https://www.gravatar.com',
'email_delivery' => nil,
'max_concurrent_ajax_uploads' => 2,
'max_attachments_at_once' => 50,
'sudo_mode' => true,
'common_mark_enable_hardbreaks' => true,
'thumbnails_generation_timeout' => 10,
test/system/issues_test.rb
assert_equal 'Some description', issue.attachments.first.description
end
def test_create_issue_should_not_attach_more_files_than_max_attachments_at_once
set_tmp_attachments_directory
log_user('jsmith', 'jsmith')
Redmine::Configuration.with('max_attachments_at_once' => 3) do
visit '/projects/ecookbook/issues/new'
end
files = %w(testfile.txt hello.pdf japanese-utf-8.txt iso8859-1.txt).map do |name|
Rails.root.join('test/fixtures/files', name)
end
accept_alert(/maximum number of files that can be attached simultaneously \(3\)/) do
attach_file 'attachments[dummy][file]', files
end
assert_selector '.attachments_fields > span', :count => 3
assert_no_selector '.add_attachment', :visible => true
end
def test_create_issue_with_new_target_version
log_user('jsmith', 'jsmith')
(5-5/5)