summaryrefslogtreecommitdiff
path: root/src/services/drive/internal-storage.ts
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2020-01-04 07:20:41 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2020-01-04 07:20:41 +0900
commite37840d870eec41599cde71baee70e3688e21f32 (patch)
treed32ba90ff25ca7491ea74beb871fdc36bc8e4101 /src/services/drive/internal-storage.ts
parent2020 (diff)
downloadmisskey-e37840d870eec41599cde71baee70e3688e21f32.tar.gz
misskey-e37840d870eec41599cde71baee70e3688e21f32.tar.bz2
misskey-e37840d870eec41599cde71baee70e3688e21f32.zip
ドライブ関連の修正 (#5673)
* :v: * Update add-file.ts * fix
Diffstat (limited to 'src/services/drive/internal-storage.ts')
-rw-r--r--src/services/drive/internal-storage.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/services/drive/internal-storage.ts b/src/services/drive/internal-storage.ts
index ff890d7d47..f8d7489a22 100644
--- a/src/services/drive/internal-storage.ts
+++ b/src/services/drive/internal-storage.ts
@@ -3,25 +3,27 @@ import * as Path from 'path';
import config from '../../config';
export class InternalStorage {
- private static readonly path = Path.resolve(`${__dirname}/../../../files`);
+ private static readonly path = Path.resolve(__dirname, '../../../files');
+
+ public static resolvePath = (key: string) => Path.resolve(InternalStorage.path, key);
public static read(key: string) {
- return fs.createReadStream(`${InternalStorage.path}/${key}`);
+ return fs.createReadStream(InternalStorage.resolvePath(key));
}
public static saveFromPath(key: string, srcPath: string) {
fs.mkdirSync(InternalStorage.path, { recursive: true });
- fs.copyFileSync(srcPath, `${InternalStorage.path}/${key}`);
+ fs.copyFileSync(srcPath, InternalStorage.resolvePath(key));
return `${config.url}/files/${key}`;
}
public static saveFromBuffer(key: string, data: Buffer) {
fs.mkdirSync(InternalStorage.path, { recursive: true });
- fs.writeFileSync(`${InternalStorage.path}/${key}`, data);
+ fs.writeFileSync(InternalStorage.resolvePath(key), data);
return `${config.url}/files/${key}`;
}
public static del(key: string) {
- fs.unlink(`${InternalStorage.path}/${key}`, () => {});
+ fs.unlink(InternalStorage.resolvePath(key), () => {});
}
}