Skip to content

Commit

Permalink
fix: Store private files in the static directory by default (#8325)
Browse files Browse the repository at this point in the history
  • Loading branch information
sradevski authored Jul 29, 2024
1 parent f9d8668 commit df734a3
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down Expand Up @@ -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<string> {
Expand Down

0 comments on commit df734a3

Please sign in to comment.