server: set file permissions after copy

This explicitly sets the file permissions to allow everyone to read files
since apparently multer sometimes doesn't set the permissions we expect.

Ref: #202
Changelog: Fixed
This commit is contained in:
Johann150 2023-01-02 12:23:47 +01:00
parent 7f564431be
commit 2a46719f31
Signed by: Johann150
GPG Key ID: 9EE6577A2A06F8F1
1 changed files with 3 additions and 1 deletions

View File

@ -18,7 +18,9 @@ export class InternalStorage {
public static saveFromPath(key: string, srcPath: string): string {
fs.mkdirSync(InternalStorage.path, { recursive: true });
fs.copyFileSync(srcPath, InternalStorage.resolvePath(key));
const target = InternalStorage.resolvePath(key);
fs.copyFileSync(srcPath, target);
fs.chmodSync(target, 0o644);
return `${config.url}/files/${key}`;
}