make file upload size limit configurable (#386)

This commit is contained in:
Philip Okugbe
2024-10-10 21:28:28 +01:00
committed by GitHub
parent e333eee08b
commit 384f11f2b7
14 changed files with 428 additions and 400 deletions

View File

@ -43,6 +43,11 @@ export class EnvironmentService {
return this.configService.get<string>('STORAGE_DRIVER', 'local');
}
getFileUploadSizeLimit(): string {
return this.configService.get<string>('FILE_UPLOAD_SIZE_LIMIT', '50mb');
}
getAwsS3AccessKeyId(): string {
return this.configService.get<string>('AWS_S3_ACCESS_KEY_ID');
}

View File

@ -21,7 +21,6 @@ import {
import { FileInterceptor } from '../../common/interceptors/file.interceptor';
import * as bytes from 'bytes';
import * as path from 'path';
import { MAX_FILE_SIZE } from '../../core/attachment/attachment.constants';
import { ImportService } from './import.service';
import { AuthWorkspace } from '../../common/decorators/auth-workspace.decorator';
@ -45,7 +44,7 @@ export class ImportController {
) {
const validFileExtensions = ['.md', '.html'];
const maxFileSize = bytes(MAX_FILE_SIZE);
const maxFileSize = bytes('100mb');
let file = null;
try {
@ -56,7 +55,7 @@ export class ImportController {
this.logger.error(err.message);
if (err?.statusCode === 413) {
throw new BadRequestException(
`File too large. Exceeds the ${MAX_FILE_SIZE} limit`,
`File too large. Exceeds the 100mb import limit`,
);
}
}

View File

@ -33,6 +33,7 @@ export class StaticModule implements OnModuleInit {
ENV: this.environmentService.getNodeEnv(),
APP_URL: this.environmentService.getAppUrl(),
IS_CLOUD: this.environmentService.isCloud(),
FILE_UPLOAD_SIZE_LIMIT: this.environmentService.getFileUploadSizeLimit()
};
const windowScriptContent = `<script>window.CONFIG=${JSON.stringify(configString)};</script>`;