diff options
| author | otofune <otofune@gmail.com> | 2017-11-14 05:26:27 +0900 |
|---|---|---|
| committer | otofune <otofune@gmail.com> | 2017-11-14 05:28:44 +0900 |
| commit | 28d2d38fce7012c6f9d48dc52a0bf2efd1e8c652 (patch) | |
| tree | 0ab13e7f967193086324d1779b53711f68d0c45a /src/api/common | |
| parent | format (diff) | |
| download | sharkey-28d2d38fce7012c6f9d48dc52a0bf2efd1e8c652.tar.gz sharkey-28d2d38fce7012c6f9d48dc52a0bf2efd1e8c652.tar.bz2 sharkey-28d2d38fce7012c6f9d48dc52a0bf2efd1e8c652.zip | |
server - multerがテンポラリディレクトリにファイルを展開するように
DiskStorageをオプション無しで呼ぶといい感じになる
またチェーンを改行するようにし、デバッグ表示にパスが出るようにした
Diffstat (limited to 'src/api/common')
| -rw-r--r-- | src/api/common/add-file-to-drive.ts | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/api/common/add-file-to-drive.ts b/src/api/common/add-file-to-drive.ts index 7defbc631a..9ed5e88744 100644 --- a/src/api/common/add-file-to-drive.ts +++ b/src/api/common/add-file-to-drive.ts @@ -40,7 +40,7 @@ const addFile = async ( folderId: mongodb.ObjectID = null, force: boolean = false ) => { - log(`registering ${name} (user: ${user.username})`); + log(`registering ${name} (user: ${user.username}, path: ${path})`); // Calculate hash, get content type and get file size const [hash, [mime, ext], size] = await Promise.all([ @@ -210,18 +210,19 @@ export default (user: any, file: string | stream.Readable, ...args) => new Promi .catch(rej); } rej(new Error('un-compatible file.')); - }).then(([path, remove]): Promise<any> => new Promise((res, rej) => { - addFile(user, path, ...args) - .then(file => { - res(file); - if (remove) { - fs.unlink(path, (e) => { - if (e) log(e.stack); - }); - } - }) - .catch(rej); - })) + }) + .then(([path, remove]): Promise<any> => new Promise((res, rej) => { + addFile(user, path, ...args) + .then(file => { + res(file); + if (remove) { + fs.unlink(path, (e) => { + if (e) log(e.stack); + }); + } + }) + .catch(rej); + })) .then(file => { log(`drive file has been created ${file._id}`); resolve(file); |