Skip to content

Commit df734a3

Browse files
authored
fix: Store private files in the static directory by default (#8325)
1 parent f9d8668 commit df734a3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/modules/providers/file-local/src/services/local-file.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ export class LocalFileService extends AbstractFileProviderService {
1212
constructor(_, options: LocalFileServiceOptions) {
1313
super()
1414
this.uploadDir_ = options?.upload_dir || path.join(process.cwd(), "static")
15+
16+
// Since there is no way to serve private files through a static server, we simply place them in `static`.
17+
// This means that the files will be available publicly if the filename is known. Since the local file provider
18+
// is for development only, this shouldn't be an issue. If you really want to use it in production (and you shouldn't)
19+
// You can change the private upload dir to `/private` but none of the functionalities where you use a presigned URL will work.
1520
this.privateUploadDir_ =
16-
options?.private_upload_dir || path.join(process.cwd(), "private")
21+
options?.private_upload_dir || path.join(process.cwd(), "static")
1722
this.backendUrl_ = options?.backend_url || "http://localhost:9000/static"
1823
}
1924

@@ -73,7 +78,7 @@ export class LocalFileService extends AbstractFileProviderService {
7378
}
7479

7580
// For private files, we simply return the file path, which can then be loaded manually by the backend.
76-
// The local file provider doesn't support presigned URLs for private files.
81+
// The local file provider doesn't support presigned URLs for private files (i.e files not placed in /static).
7782
async getPresignedDownloadUrl(
7883
file: FileTypes.ProviderGetFileDTO
7984
): Promise<string> {

0 commit comments

Comments
 (0)