let final = fs.createWriteStream(this.final_temp_file, {flags: 'a'});
// must be inside of an async function
for (const part of parts) {
await pipeFileToWriteStream(part.file.path, final);
}
// ...
async function pipeFileToWriteStream(path, stream) {
return await new Promise((resolve, reject) => {
const r = fs.createReadStream(path);
r.on('close', resolve);
r.on('error', reject);
r.pipe(stream);
});
}