Browse Source

fix(test): Made defealt file field size limit to 250MB and is configurable using NC_FILE_FIELD_SIZE env variable

pull/4538/head
Muhammed Mustafa 2 years ago
parent
commit
5d234732e2
  1. 3
      packages/nocodb/src/lib/constants/index.ts
  2. 4
      packages/nocodb/src/lib/meta/NcMetaMgr.ts
  3. 4
      packages/nocodb/src/lib/meta/NcMetaMgrv2.ts
  4. 4
      packages/nocodb/src/lib/meta/api/attachmentApis.ts
  5. 4
      packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts

3
packages/nocodb/src/lib/constants/index.ts

@ -1,2 +1,5 @@
export const NC_LICENSE_KEY = 'nc-license-key';
export const NC_APP_SETTINGS = 'nc-app-settings';
export const NC_FILE_FIELD_SIZE = process.env['NC_FILE_FIELD_SIZE']
? Number(process.env['NC_FILE_FIELD_SIZE'])
: 250 * 1024 * 1024; // 250 MB

4
packages/nocodb/src/lib/meta/NcMetaMgr.ts

@ -41,6 +41,7 @@ import { defaultConnectionConfig } from '../utils/NcConfigFactory';
import xcMetaDiff from './handlers/xcMetaDiff';
import { UITypes } from 'nocodb-sdk';
import { Tele } from 'nc-help';
import { NC_FILE_FIELD_SIZE } from '../constants';
const randomID = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz_', 10);
const XC_PLUGIN_DET = 'XC_PLUGIN_DET';
@ -132,6 +133,9 @@ export default class NcMetaMgr {
storage: multer.diskStorage({
// dest: path.join(this.config.toolDir, 'uploads')
}),
limits: {
fieldSize: NC_FILE_FIELD_SIZE,
},
});
// router.post(this.config.dashboardPath, upload.single('file'));
router.post(this.config.dashboardPath, upload.any());

4
packages/nocodb/src/lib/meta/NcMetaMgrv2.ts

@ -11,6 +11,7 @@ import NcPluginMgr from '../v1-legacy/plugins/NcPluginMgr';
import NcMetaIO from './NcMetaIO';
import { defaultConnectionConfig } from '../utils/NcConfigFactory';
import ncCreateLookup from './handlersv2/ncCreateLookup';
import { NC_FILE_FIELD_SIZE } from '../constants';
// import ncGetMeta from './handlersv2/ncGetMeta';
export default class NcMetaMgrv2 {
@ -71,6 +72,9 @@ export default class NcMetaMgrv2 {
storage: multer.diskStorage({
// dest: path.join(this.config.toolDir, 'uploads')
}),
limits: {
fieldSize: NC_FILE_FIELD_SIZE,
},
});
// router.post(this.config.dashboardPath, upload.single('file'));
router.post(this.config.dashboardPath, upload.any());

4
packages/nocodb/src/lib/meta/api/attachmentApis.ts

@ -9,6 +9,7 @@ import { Tele } from 'nc-help';
import ncMetaAclMw from '../helpers/ncMetaAclMw';
import catchError from '../helpers/catchError';
import NcPluginMgrv2 from '../helpers/NcPluginMgrv2';
import { NC_FILE_FIELD_SIZE } from '../../constants';
// const storageAdapter = new Local();
export async function upload(req: Request, res: Response) {
@ -151,6 +152,9 @@ router.post(
'/api/v1/db/storage/upload',
multer({
storage: multer.diskStorage({}),
limits: {
fieldSize: NC_FILE_FIELD_SIZE,
},
}).any(),
ncMetaAclMw(upload, 'upload')
);

4
packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts

@ -18,6 +18,7 @@ import slash from 'slash';
import { sanitizeUrlPath } from '../attachmentApis';
import getAst from '../../../db/sql-data-mapper/lib/sql/helpers/getAst';
import { getColumnByIdOrName } from '../dataApis/helpers';
import { NC_FILE_FIELD_SIZE } from '../../../constants';
export async function dataList(req: Request, res: Response) {
try {
@ -451,6 +452,9 @@ router.post(
'/api/v1/db/public/shared-view/:sharedViewUuid/rows',
multer({
storage: multer.diskStorage({}),
limits: {
fieldSize: NC_FILE_FIELD_SIZE,
},
}).any(),
catchError(dataInsert)
);

Loading…
Cancel
Save