-
Notifications
You must be signed in to change notification settings - Fork 7
multipart/form-data fixes #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
This fix doesn't fix the inability to use From what I understand, the remaining issue occurs in const { router, server } = require('0http')({
server: require('../src/server')()
})
const Busboy = require('busboy')
router.post('/upload', (req, res) => {
const busboy = new Busboy({ headers: req.headers })
busboy.on('file', function (fieldname, file, filename, encoding, mimetype) {
console.log('File [' + fieldname + ']: filename: ' + filename + ', encoding: ' + encoding + ', mimetype: ' + mimetype)
file.on('data', function (data) {
console.log(data.toString()) // this should show the data we are trying to send via curl
console.log('File [' + fieldname + '] got ' + data.length + ' bytes')
})
file.on('end', function () {
console.log('File [' + fieldname + '] Finished')
})
})
req.pipe(busboy)
})
server.listen(3000, () => { })I tried using The busboy code produced the following result in terminal: So, my understanding is that multer uses some additional node.js APIs that @herudi: |
|
I'm try your code using busboy and still hang on twice request . . server.js ...
res.onData((bytes, isLast) => {
if (!bytes.byteLength) {
if (!isLast) return
return handler(reqWrapper, resWrapper)
}
const chunk = Buffer.from(bytes)
if (isLast) {
reqWrapper.push(chunk)
reqWrapper.push(null)
if (!res.finished) {
return handler(reqWrapper, resWrapper)
}
return
}
return reqWrapper.push(chunk)
})
...Example upload const { router, server } = require('0http')({
server: require('../src/server')()
})
const Busboy = require('busboy')
router.post('/upload', (req, res) => {
const busboy = new Busboy({ headers: req.headers })
busboy.on('file', function (fieldname, file, filename, encoding, mimetype) {
console.log('File [' + fieldname + ']: filename: ' + filename + ', encoding: ' + encoding + ', mimetype: ' + mimetype)
file.on('data', function (data) {
// console.log(data.toString()) // this should show the data we are trying to send via curl
console.log('File [' + fieldname + '] got ' + data.length + ' bytes')
})
file.on('end', function () {
console.log('File [' + fieldname + '] Finished')
})
})
req.pipe(busboy)
})
server.listen(3000, () => { })
Expect File ['file]: filename: test.txt, encoding: 7bit, mimetype: text/plain
test 1234
File ['file] got 6 bytes
File ['file] Finishedany idea ? thanks... |
|
@herudi have you tried the latest NPM version or the last commit in |
|
@schamberg97 yes, i use the last commit master and latest yarn... but the original last commit master error in here _read (size) {
return this.slice(0, size)
}just modify file in request.js and server.js from u right? but still hang.. thanks |
|
Yup, sorry, was in a bit of a rush. Yeah, I actually meant changes in this Pull Request. Does it work with changes in this PR? Because for me, it does work |
|
sorry, for me it hangs for next requests. next request means, send with curl then stop curl and send again it will hang. so I tried it several times thanks... |
|
@herudi weird, I have no such issue while using this unmerged PR. I have tried it on MacOS, so I will try on Windows, perhaps I can reproduce it there |
|
well,, maybe you should try it on windows too. i am also using nodejs 12.x version. in the meantime. thanks... |
|
Hi @schamberg97, thanks for supporting this issue. Should we go ahead and merge this PR? |

Fixes hangs that may occur with multipart/form-data file uploads. Influenced by #13 (comment) .