From df734a3ce9d3dddfb2300d2c7105a3be73cf7a48 Mon Sep 17 00:00:00 2001 From: Stevche Radevski Date: Mon, 29 Jul 2024 12:41:47 +0300 Subject: [PATCH] fix: Store private files in the static directory by default (#8325) --- .../providers/file-local/src/services/local-file.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/modules/providers/file-local/src/services/local-file.ts b/packages/modules/providers/file-local/src/services/local-file.ts index 71eb1ad99c..312246f076 100644 --- a/packages/modules/providers/file-local/src/services/local-file.ts +++ b/packages/modules/providers/file-local/src/services/local-file.ts @@ -12,8 +12,13 @@ export class LocalFileService extends AbstractFileProviderService { constructor(_, options: LocalFileServiceOptions) { super() this.uploadDir_ = options?.upload_dir || path.join(process.cwd(), "static") + + // Since there is no way to serve private files through a static server, we simply place them in `static`. + // This means that the files will be available publicly if the filename is known. Since the local file provider + // is for development only, this shouldn't be an issue. If you really want to use it in production (and you shouldn't) + // You can change the private upload dir to `/private` but none of the functionalities where you use a presigned URL will work. this.privateUploadDir_ = - options?.private_upload_dir || path.join(process.cwd(), "private") + options?.private_upload_dir || path.join(process.cwd(), "static") this.backendUrl_ = options?.backend_url || "http://localhost:9000/static" } @@ -73,7 +78,7 @@ export class LocalFileService extends AbstractFileProviderService { } // For private files, we simply return the file path, which can then be loaded manually by the backend. - // The local file provider doesn't support presigned URLs for private files. + // The local file provider doesn't support presigned URLs for private files (i.e files not placed in /static). async getPresignedDownloadUrl( file: FileTypes.ProviderGetFileDTO ): Promise {