From f16c5d91baa7efe1c077aac7e53ae4dd6ca4b2e6 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Sat, 4 Jan 2025 09:35:35 +0100 Subject: [PATCH] changed file storage path --- .dockerignore | 2 +- .gitignore | 2 +- README.md | 2 +- src/controller/admin/protocolController.ts | 6 ++++-- src/helpers/fileSystemHelper.ts | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index 4b56232..9ede668 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,5 +2,5 @@ node_modules/ dist/ .git/ -export/ +files/ .env \ No newline at end of file diff --git a/.gitignore b/.gitignore index 89904f3..7efd6b5 100644 --- a/.gitignore +++ b/.gitignore @@ -130,6 +130,6 @@ dist .yarn/install-state.gz .pnp.* -export +files .idea \ No newline at end of file diff --git a/README.md b/README.md index 670a481..e146e48 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ services: - CLUB_NAME= - CLUB_WEBSITE= volumes: - - :/app/export + - :/app/files networks: - ff_internal depends_on: diff --git a/src/controller/admin/protocolController.ts b/src/controller/admin/protocolController.ts index a82608f..60b1e30 100644 --- a/src/controller/admin/protocolController.ts +++ b/src/controller/admin/protocolController.ts @@ -143,7 +143,9 @@ export async function getProtocolPrintoutByIdAndPrint(req: Request, res: Respons let printout = await ProtocolPrintoutService.getById(printoutId, protocolId); - res.sendFile(process.cwd() + `/export/${printout.filename}.pdf`, { + let filepath = FileSystemHelper.formatPath("protocol", printout.filename); + + res.sendFile(filepath, { headers: { "Content-Type": "application/pdf", }, @@ -264,7 +266,7 @@ export async function createProtocolPrintoutById(req: Request, res: Response): P let printout: CreateProtocolPrintoutCommand = { title, iteration: iteration + 1, - filename: FileSystemHelper.normalizePath("protocol", filename), + filename: `${filename}.pdf`, protocolId, }; await ProtocolPrintoutCommandHandler.create(printout); diff --git a/src/helpers/fileSystemHelper.ts b/src/helpers/fileSystemHelper.ts index 5813f6a..db6b95e 100644 --- a/src/helpers/fileSystemHelper.ts +++ b/src/helpers/fileSystemHelper.ts @@ -29,7 +29,7 @@ export abstract class FileSystemHelper { } static formatPath(...args: string[]) { - return join(process.cwd(), "export", ...args); + return join(process.cwd(), "files", ...args); } static normalizePath(...args: string[]) {