Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
fix: parser does not end until file data is consumed
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
  • Loading branch information
Alan Shaw committed Jan 29, 2019
1 parent 8d5deb9 commit af4d6f7
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/http/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,14 @@ const mfsWrite = {

const fileStream = await new Promise((resolve, reject) => {
const parser = multipart.reqParser(request.payload)
let fileStream

parser.on('file', (_, stream) => {
if (fileStream) {
return reject(Boom.badRequest('Please only send one file'))
}

fileStream = stream
resolve(stream)
})

parser.on('error', (error) => {
reject(error)
})

parser.on('end', () => {
resolve(fileStream)
})
})

await ipfs.files.write(arg, fileStream, {
Expand Down

0 comments on commit af4d6f7

Please sign in to comment.