Skip to content

Commit 2250044

Browse files
authored
feat: Allow admin to override the maximum file upload size
Original configuration had a hard-coded limit of 20MB per file supplied to the platform. This change will retain the existing 20MB limit as default, but provide the admin with the ability to override the value via the MFE_CONFIG API (getConfig) The new function includes validation to check that the override value supplied is in fact a valid and positive integer and reverts to default 20MB in case of validation failure
1 parent 0820a1e commit 2250044

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/constants.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { getConfig } from '@edx/frontend-platform';
2+
13
export const DATE_FORMAT = 'MM/dd/yyyy';
24
export const TIME_FORMAT = 'HH:mm';
35
export const DATE_TIME_FORMAT = 'YYYY-MM-DDTHH:mm:ss\\Z';
@@ -52,7 +54,16 @@ export const DECODED_ROUTES = {
5254
],
5355
};
5456

55-
export const UPLOAD_FILE_MAX_SIZE = 20 * 1024 * 1024; // 100mb
57+
// FilesUpload page - Default max size: 20MB else use env override if exists and valid number
58+
const DEFAULT_UPLOAD_FILE_MAX_SIZE = 20 * 1024 * 1024; // 20 MB
59+
60+
export const getUploadFileMaxSize = () => {
61+
const config = getConfig();
62+
const overrideMaxFileSizeMB = parseInt(config.OVERRIDE_UPLOAD_FILE_MAX_SIZE_IN_MB, 10);
63+
return !Number.isNaN(overrideMaxFileSizeMB) && overrideMaxFileSizeMB > 0
64+
? overrideMaxFileSizeMB * 1024 * 1024
65+
: DEFAULT_UPLOAD_FILE_MAX_SIZE;
66+
};
5667

5768
export const COURSE_BLOCK_NAMES = ({
5869
chapter: { id: 'chapter', name: 'Section' },

0 commit comments

Comments
 (0)