fix(api): resolve when file is done being written to fs rather than when read stream ends

This commit is contained in:
Samuel Horton 2018-03-22 16:43:38 -07:00
parent 58d6ec76a9
commit 07f24fb414

View File

@ -26,8 +26,9 @@ const storeFS = ({ stream, filename }) => {
fs.unlinkSync(path)
reject(error)
})
.on('end', () => resolve({ id, path }))
.pipe(fs.createWriteStream(path))
.on('error', error => reject(error))
.on('finish', () => resolve({ id, path }))
)
}