diff --git a/packages/nocodb-nest/src/modules/attachments/attachments.controller.ts b/packages/nocodb-nest/src/modules/attachments/attachments.controller.ts index c423ac17e2..6c6c6f2fc6 100644 --- a/packages/nocodb-nest/src/modules/attachments/attachments.controller.ts +++ b/packages/nocodb-nest/src/modules/attachments/attachments.controller.ts @@ -13,10 +13,7 @@ import { UseGuards, UseInterceptors, } from '@nestjs/common'; -import multer from 'multer'; import { AnyFilesInterceptor } from '@nestjs/platform-express'; -import { AuthGuard } from '@nestjs/passport'; -import { NC_ATTACHMENT_FIELD_SIZE } from '../../constants'; import { GlobalGuard } from '../../guards/global/global.guard'; import { UploadAllowedInterceptor } from '../../interceptors/is-upload-allowed/is-upload-allowed.interceptor'; import { AttachmentsService } from './attachments.service'; @@ -26,31 +23,9 @@ export class AttachmentsController { constructor(private readonly attachmentsService: AttachmentsService) {} @UseGuards(GlobalGuard) - @Post( - '/api/v1/db/storage/upload', - // multer({ - // storage: multer.diskStorage({}), - // limits: { - // fieldSize: NC_ATTACHMENT_FIELD_SIZE, - // }, - // }).any(), - // [ - // extractProjectIdAndAuthenticate, - // catchError(isUploadAllowedMw), - // catchError(upload), - // ] - // ); - ) + @Post('/api/v1/db/storage/upload') @HttpCode(200) - @UseInterceptors( - UploadAllowedInterceptor, - AnyFilesInterceptor({ - storage: multer.diskStorage({}), - limits: { - fieldSize: NC_ATTACHMENT_FIELD_SIZE, - }, - }), - ) + @UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor()) async upload( @UploadedFiles() files: Array, @Body() body: any, @@ -68,12 +43,6 @@ export class AttachmentsController { @Post('/api/v1/db/storage/upload-by-url') @HttpCode(200) @UseInterceptors(UploadAllowedInterceptor) - // [ - // extractProjectIdAndAuthenticate, - // catchError(isUploadAllowedMw), - // catchError(uploadViaURL), - // ] - // ); @UseGuards(GlobalGuard) async uploadViaURL(@Body() body: any, @Query('path') path: string) { const attachments = await this.attachmentsService.uploadViaURL({ diff --git a/packages/nocodb-nest/src/modules/attachments/attachments.module.ts b/packages/nocodb-nest/src/modules/attachments/attachments.module.ts index 37d2bab2cc..e20196b664 100644 --- a/packages/nocodb-nest/src/modules/attachments/attachments.module.ts +++ b/packages/nocodb-nest/src/modules/attachments/attachments.module.ts @@ -1,8 +1,19 @@ import { Module } from '@nestjs/common'; +import { MulterModule } from '@nestjs/platform-express'; +import multer from 'multer'; +import { NC_ATTACHMENT_FIELD_SIZE } from '../../constants'; import { AttachmentsService } from './attachments.service'; import { AttachmentsController } from './attachments.controller'; @Module({ + imports: [ + MulterModule.register({ + storage: multer.diskStorage({}), + limits: { + fieldSize: NC_ATTACHMENT_FIELD_SIZE, + }, + }), + ], controllers: [AttachmentsController], providers: [AttachmentsService], }) diff --git a/packages/nocodb-nest/src/modules/hooks/hooks.controller.ts b/packages/nocodb-nest/src/modules/hooks/hooks.controller.ts index 28af2d3b60..ceb5bd9457 100644 --- a/packages/nocodb-nest/src/modules/hooks/hooks.controller.ts +++ b/packages/nocodb-nest/src/modules/hooks/hooks.controller.ts @@ -11,7 +11,6 @@ import { UseGuards, } from '@nestjs/common'; import { HookReqType, HookTestReqType } from 'nocodb-sdk'; -import { AuthGuard } from '@nestjs/passport'; import { GlobalGuard } from '../../guards/global/global.guard'; import { PagedResponseImpl } from '../../helpers/PagedResponse'; import { diff --git a/packages/nocodb-nest/src/modules/public-datas/public-datas.controller.ts b/packages/nocodb-nest/src/modules/public-datas/public-datas.controller.ts index 792266c05b..acc5c53680 100644 --- a/packages/nocodb-nest/src/modules/public-datas/public-datas.controller.ts +++ b/packages/nocodb-nest/src/modules/public-datas/public-datas.controller.ts @@ -45,15 +45,21 @@ export class PublicDatasController { return groupedData; } + // todo: multer + // router.post( + // '/api/v1/db/public/shared-view/:sharedViewUuid/rows', + // multer({ + // storage: multer.diskStorage({}), + // limits: { + // fieldSize: NC_ATTACHMENT_FIELD_SIZE, + // }, + // }).any(), + // catchError(dataInsert) + // ); @Post('/api/v1/db/public/shared-view/:sharedViewUuid/rows') @HttpCode(200) @UseInterceptors( - AnyFilesInterceptor({ - storage: multer.diskStorage({}), - limits: { - fieldSize: NC_ATTACHMENT_FIELD_SIZE, - }, - }), + AnyFilesInterceptor(), ) async dataInsert( @Request() req, diff --git a/packages/nocodb-nest/src/modules/public-datas/public-datas.module.ts b/packages/nocodb-nest/src/modules/public-datas/public-datas.module.ts index 3a068a7427..9de97e3c3c 100644 --- a/packages/nocodb-nest/src/modules/public-datas/public-datas.module.ts +++ b/packages/nocodb-nest/src/modules/public-datas/public-datas.module.ts @@ -10,7 +10,7 @@ import { PublicDatasController } from './public-datas.controller'; MulterModule.register({ storage: multer.diskStorage({}), limits: { - fileSize: NC_ATTACHMENT_FIELD_SIZE, + fieldSize: NC_ATTACHMENT_FIELD_SIZE, }, }), ],