diff --git a/src/api/common/add-file-to-drive.ts b/src/api/common/add-file-to-drive.ts index 1aa21f71a..5f7d255e4 100644 --- a/src/api/common/add-file-to-drive.ts +++ b/src/api/common/add-file-to-drive.ts @@ -94,13 +94,16 @@ export default ( ((): Promise => new Promise((res, rej) => { const readable = fs.createReadStream(path); const hash = crypto.createHash('md5'); + const chunks = []; readable .on('error', rej) - .on('end', () => { - res(hash.digest('hex')); - }) .pipe(hash) - .on('error', rej); + .on('error', rej) + .on('data', (chunk) => chunks.push(chunk)) + .on('end', () => { + const buffer = Buffer.concat(chunks); + res(buffer.toString('hex')); + }); }))(), // mime ((): Promise<[string, string | null]> => new Promise((res, rej) => {