Skip to content

Commit a127ba6

Browse files
authored
Update constants.js
1 parent befb360 commit a127ba6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/constants.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getConfig } from '@edx/frontend-platform';
12
export const DATE_FORMAT = 'MM/dd/yyyy';
23
export const TIME_FORMAT = 'HH:mm';
34
export const DATE_TIME_FORMAT = 'YYYY-MM-DDTHH:mm:ss\\Z';
@@ -53,14 +54,15 @@ export const DECODED_ROUTES = {
5354
};
5455

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

6567
export const COURSE_BLOCK_NAMES = ({
6668
chapter: { id: 'chapter', name: 'Section' },

0 commit comments

Comments
 (0)