From 354db0c1a2f6d2c3889974e75ed078691979872d Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Wed, 31 Mar 2021 22:58:15 +0200 Subject: [PATCH 1/3] MediaConfigMock: Change upload path This changes the upload path in all test to 'test_uploads' to ensure no real uploads are lost. Signed-off-by: Philip Molares --- src/config/mock/media.config.mock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/mock/media.config.mock.ts b/src/config/mock/media.config.mock.ts index 3f729d34c..175253e33 100644 --- a/src/config/mock/media.config.mock.ts +++ b/src/config/mock/media.config.mock.ts @@ -10,7 +10,7 @@ export default registerAs('mediaConfig', () => ({ backend: { use: 'filesystem', filesystem: { - uploadPath: 'uploads', + uploadPath: 'test_uploads', }, }, })); From c821fe6f040b8e6a38d560de03cb953601ee78de Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Wed, 31 Mar 2021 22:59:47 +0200 Subject: [PATCH 2/3] Git: Ignore test_uploads folder Ignore the uploads folder for tests. Signed-off-by: Philip Molares --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f8aa626e6..99a0704cb 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ dist public/uploads/* !public/uploads/.gitkeep uploads +test_uploads From 4fb76232250a121ec65f29b6f0d28161912d0321 Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Wed, 31 Mar 2021 23:01:29 +0200 Subject: [PATCH 3/3] FileMediaBackend: Fix generated urls All urls should be of the form `uploads/.` regardless of what the uploadDirectory is, because the backend proxies all locally uploaded files. Signed-off-by: Philip Molares --- src/media/backends/filesystem-backend.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/media/backends/filesystem-backend.ts b/src/media/backends/filesystem-backend.ts index cf9ce7cce..42924d288 100644 --- a/src/media/backends/filesystem-backend.ts +++ b/src/media/backends/filesystem-backend.ts @@ -36,7 +36,7 @@ export class FilesystemBackend implements MediaBackend { await this.ensureDirectory(); try { await fs.writeFile(filePath, buffer, null); - return ['/' + filePath, null]; + return ['/uploads/' + fileName, null]; } catch (e) { this.logger.error((e as Error).message, (e as Error).stack, 'saveFile'); throw new MediaBackendError(`Could not save '${filePath}'`);