Skip to content

Commit 4e83229

Browse files
authored
BC-11223 - Add CSV file size limit (#3750)
1 parent 982416d commit 4e83229

File tree

7 files changed

+14
-2
lines changed

7 files changed

+14
-2
lines changed

config/default.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,11 @@
569569
"MAX_FILE_SIZE"
570570
]
571571
},
572+
"CSV_IMPORT_MAX_FILE_SIZE": {
573+
"type": "integer",
574+
"default": 512000,
575+
"description": "Maximum file size for incoming requests in Byte, sync with nginx config"
576+
},
572577
"FEATURE_CONSENT_NECESSARY": {
573578
"type": "boolean",
574579
"default": true,

controllers/administration.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ const redirectHelper = require('../helpers/redirect');
1818
const timesHelper = require('../helpers/timesHelper');
1919

2020
const router = express.Router();
21-
const upload = multer({ storage: multer.memoryStorage() });
21+
const upload = multer({
22+
storage: multer.memoryStorage(),
23+
limits: { fileSize: Configuration.get('CSV_IMPORT_MAX_FILE_SIZE') },
24+
});
2225

2326
const { HOST, CONSENT_WITHOUT_PARENTS_MIN_AGE_YEARS } = require('../config/global');
2427
const { isUserHidden } = require('../helpers/users');

locales/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@
280280
"form_Import": {
281281
"label": {
282282
"selectCSVFile": "CSV-Datei auswählen",
283+
"fileSizeInfo" : "max. Dateigröße",
283284
"sendRegistrationLinkToUsers": "Registrierungslinks sofort nach Import an Nutzer:in senden"
284285
},
285286
"text": {

locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@
280280
"form_Import": {
281281
"label": {
282282
"selectCSVFile": "Select CSV file",
283+
"fileSizeInfo" : "max file size",
283284
"sendRegistrationLinkToUsers": "Send registration links to users immediately after import"
284285
},
285286
"text": {

locales/es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@
280280
"form_Import": {
281281
"label": {
282282
"selectCSVFile": "Seleccionar archivo CSV",
283+
"fileSizeInfo" : "tamaño máximo de archivo",
283284
"sendRegistrationLinkToUsers": "Enviar enlaces de registro a los usuarios inmediatamente después de la importación"
284285
},
285286
"text": {

locales/uk.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@
979979
"form_Import": {
980980
"label": {
981981
"selectCSVFile": "Вибрати CSV-файл",
982+
"fileSizeInfo" : "максимальний розмір файлу",
982983
"sendRegistrationLinkToUsers": "Відразу після імпорту надсилайте користувачам посилання для реєстрації"
983984
},
984985
"text": {

views/administration/forms/form-import.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<img src="{{getAssetPath '/images/csv_example.png'}}" />
1010
</p>
1111
<div class="form-group">
12-
<label>{{$t "administration.form_Import.label.selectCSVFile" }}</label>
12+
<label>{{$t "administration.form_Import.label.selectCSVFile" }} ({{$t "administration.form_Import.label.fileSizeInfo" }} {{ writeFileSizePretty (getConfig "CSV_IMPORT_MAX_FILE_SIZE") }})</label>
1313
<input class="form-control" name="csvFile" type="file" required />
1414
</div>
1515
<div class="form-group">

0 commit comments

Comments
 (0)