fix: Store private files in the static directory by default (#8325)
This commit is contained in:
@@ -12,8 +12,13 @@ export class LocalFileService extends AbstractFileProviderService {
|
|||||||
constructor(_, options: LocalFileServiceOptions) {
|
constructor(_, options: LocalFileServiceOptions) {
|
||||||
super()
|
super()
|
||||||
this.uploadDir_ = options?.upload_dir || path.join(process.cwd(), "static")
|
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_ =
|
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"
|
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.
|
// 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(
|
async getPresignedDownloadUrl(
|
||||||
file: FileTypes.ProviderGetFileDTO
|
file: FileTypes.ProviderGetFileDTO
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
|||||||
Reference in New Issue
Block a user