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

Let FileStream support bytesRead. #174

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
package-lock.json
3 changes: 3 additions & 0 deletions lib/types/multipart.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ function Multipart(boy, cfg) {
cb();
}
});

file.bytesRead = 0;
file._read = function(n) {
if (!self._pause)
return;
Expand All @@ -222,6 +224,7 @@ function Multipart(boy, cfg) {
part.removeAllListeners('data');
} else if (!file.push(data))
self._pause = true;
file.bytesRead = nsize > fileSizeLimit? fileSizeLimit: nsize;
};

onEnd = function() {
Expand Down
26 changes: 21 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ "name": "busboy",
{
"name": "busboy",
"version": "0.2.14",
"author": "Brian White <[email protected]>",
"description": "A streaming parser for HTML form data for node.js",
Expand All @@ -10,8 +11,23 @@
"scripts": {
"test": "node test/test.js"
},
"engines": { "node": ">=0.8.0" },
"keywords": [ "uploads", "forms", "multipart", "form-data" ],
"licenses": [ { "type": "MIT", "url": "http://github.com/mscdex/busboy/raw/master/LICENSE" } ],
"repository" : { "type": "git", "url": "http://github.com/mscdex/busboy.git" }
"engines": {
"node": ">=0.8.0"
},
"keywords": [
"uploads",
"forms",
"multipart",
"form-data"
],
"licenses": [
{
"type": "MIT",
"url": "http://github.com/mscdex/busboy/raw/master/LICENSE"
}
],
"repository": {
"type": "git",
"url": "http://github.com/mscdex/busboy.git"
}
}
2 changes: 2 additions & 0 deletions test/test-types-multipart.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ function next() {
info[2] = nb;
if (stream.truncated)
++info[3];

assert(typeof(stream.bytesRead) === 'number', makeMsg('file.bytesRead', 'is missing'))
});
});
}
Expand Down