Skip to content
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

No file length #32

Open
iliakan opened this issue Apr 3, 2016 · 1 comment
Open

No file length #32

iliakan opened this issue Apr 3, 2016 · 1 comment

Comments

@iliakan
Copy link

iliakan commented Apr 3, 2016

Probably a follow-up to #22: no length property.

https://github.com/andrewrk/node-multiparty provides part.byteCount (where possible), could be nice to have it here. Guess, an issue for the original busboy?

@lucaszong
Copy link

at index.js line 90: modified source code bellower:
function onFile(fieldname, file, filename, encoding, mimetype) {
if (checkFile) {
// var err = checkFile(fieldname, file, filename, encoding, mimetype)
// if (err) {
// // make sure request stream's data has been read
// var blackHoleStream = new BlackHoleStream();
// file.pipe(blackHoleStream);
// return onError(err)
// }
checkFile(fieldname, file, filename, encoding, mimetype, function (err) {
if (err) {
// make sure request stream's data has been read
var blackHoleStream = new BlackHoleStream();
file.pipe(blackHoleStream);
return onError(err)
}
})

}

======================then = at your app code =========
parts = parse(this, {
"checkFile": function (fieldname, file, filename, encoding, mimetype,cb) {
file.on("limit", function () {
var err = new Error('=====file size ======')
err.code = 'Request_fileSize_limit'
err.status = 400;
cb(err);
//return err;
});

        }, "limits": { "fileSize": 10000000 }
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants