diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..504afef --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +package-lock.json diff --git a/lib/types/multipart.js b/lib/types/multipart.js index d33492a..ce2c055 100644 --- a/lib/types/multipart.js +++ b/lib/types/multipart.js @@ -200,6 +200,8 @@ function Multipart(boy, cfg) { cb(); } }); + + file.bytesRead = 0; file._read = function(n) { if (!self._pause) return; @@ -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() { diff --git a/package.json b/package.json index 4d834b0..fa16754 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ -{ "name": "busboy", +{ + "name": "busboy", "version": "0.2.14", "author": "Brian White ", "description": "A streaming parser for HTML form data for node.js", @@ -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" + } } diff --git a/test/test-types-multipart.js b/test/test-types-multipart.js index d564049..d97870e 100644 --- a/test/test-types-multipart.js +++ b/test/test-types-multipart.js @@ -299,6 +299,8 @@ function next() { info[2] = nb; if (stream.truncated) ++info[3]; + + assert(typeof(stream.bytesRead) === 'number', makeMsg('file.bytesRead', 'is missing')) }); }); }