Merge pull request #4 from SavePointSam/file_upload_race

fix(api): resolve when file is done being written to fs
This commit is contained in:
Jayden Seric 2018-03-23 11:04:51 +11:00 committed by GitHub
commit 46978af0af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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 }))
)
}