From 5a7be6e1841b85f6f959479ee3f61e8ea7e4a1fc Mon Sep 17 00:00:00 2001 From: Nevo David Date: Mon, 7 Oct 2024 22:19:24 +0700 Subject: [PATCH] feat: fixed file path --- apps/backend/src/api/routes/media.controller.ts | 5 ++--- libraries/nestjs-libraries/src/upload/local.storage.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/backend/src/api/routes/media.controller.ts b/apps/backend/src/api/routes/media.controller.ts index 796ea6f5..9daccbef 100644 --- a/apps/backend/src/api/routes/media.controller.ts +++ b/apps/backend/src/api/routes/media.controller.ts @@ -43,9 +43,8 @@ export class MediaController { @GetOrgFromRequest() org: Organization, @UploadedFile() file: Express.Multer.File ) { - const uploadedFile = await this.storage.uploadFile(file); - const filePath = uploadedFile.path.replace(process.env.UPLOAD_DIRECTORY, basename(process.env.UPLOAD_DIRECTORY)); - return this._mediaService.saveFile(org.id, uploadedFile.originalname, filePath); + const uploadedFile = await this.storage.uploadFile(file); + return this._mediaService.saveFile(org.id, uploadedFile.originalname, uploadedFile.path); } @Post('/upload-simple') diff --git a/libraries/nestjs-libraries/src/upload/local.storage.ts b/libraries/nestjs-libraries/src/upload/local.storage.ts index 9d979889..88b7722f 100644 --- a/libraries/nestjs-libraries/src/upload/local.storage.ts +++ b/libraries/nestjs-libraries/src/upload/local.storage.ts @@ -54,7 +54,7 @@ export class LocalStorage implements IUploadProvider { const publicPath = `${innerPath}/${randomName}${extname( file.originalname )}`; - console.log(filePath); + // Logic to save the file to the filesystem goes here writeFileSync(filePath, file.buffer);