Permalink
Browse files

api cleanup

  • Loading branch information...
1 parent 9a125d2 commit 25181673ca3b4b54fb26d6dfee3f677e3634fab8 @coolaj86 committed Nov 10, 2012
Showing with 17 additions and 9 deletions.
  1. +13 −6 README.md
  2. +4 −3 good-form.js
View
@@ -10,7 +10,6 @@ Also, you'd probably really like PoorForm.
## API
* `GoodForm.create(request, options)`
- * `GoodForm.pump(readableStream, filepath)`
* `GoodForm#on('progress', fn)`
* `GoodForm#on('field', fn)`
* `GoodForm#on('file', fn)`
@@ -19,6 +18,8 @@ Also, you'd probably really like PoorForm.
* `GoodFile#type`
* `GoodFile#lastModifiedDate`
* `GoodFile#path`
+ * `GoodFile#headers`
+ * `GoodFile#<hashtype>`
* `GoodForm#on('end', fn)`
* `GoodForm#parse()`
@@ -31,10 +32,10 @@ Like PoorForm, it returns null if either it's not a multi-part form or the form
#### Options
{
- tmpDir: null || pathString || os.tmpDir() /*default*/
- , hashes: ["md5", "sha1", ...] || [] /*default*/
- , fieldNames: [fieldNameString] || [] /*default*/
- , arrayFields: [fieldNameString] || fieldNames /*default*/
+ tmpDir: null || pathString || os.tmpDir()
+ , hashes: ["md5", "sha1", ...] || []
+ , fieldNames: [fieldNameString] || []
+ , singleFields: [fieldNameString] || []
}
##### tmpDir
@@ -131,7 +132,7 @@ Treating all fields as files would have unneccesary overhead in parsing.
What you're likely to do with a field (store it in a database as metadata)
is different from what you'll do with a file (store it in a file system).
-The hybrid approach of maping pure arrays makes it simple to ignore (and or error check)
+The hybrid approach of mapping pure arrays makes it simple to ignore (and or error check)
duplicate fields that should have been singular without the confusion of other common methodologies
(see below).
@@ -150,3 +151,9 @@ The downside to this solution is that it requires parsing field names.
## Future Enhancements
needs an abstracted `error` event for both `PoorForm` and `http#request`
+
+default max size of field name length (256b)
+
+default max size of field buffer length (1mb?)
+
+optional max size of file buffer length (1mb?)
View
@@ -45,7 +45,9 @@
this.length = null; // alias of size
this.type = headers.type;
this.name = headers.filename;
+ this.fieldname = headers.name;
this.lastModifiedDate = null;
+ this.headers = headers;
}
util.inherits(GoodFile, EventEmitter);
GoodFile.prototype.pause = function () {
@@ -110,15 +112,14 @@
curField = null;
curFile = new GoodFile(req, headers);
- curFile.headers = headers;
filesMap[headers.name].push(curFile);
filesArr.push(curFile);
if (options.hashes.length) {
startHashing(curFile, options.hashes);
}
- poorForm.emit('file', headers.name, curFile);
+ poorForm.emit('file', headers.name /*form name, not file name*/, curFile);
if (null !== options.path) {
curFile.pipe(fs.createWriteStream(path.join(options.path, UUID.v4())));
}
@@ -129,7 +130,7 @@
curFile = null;
curField = {
- name: headers.name
+ name: decodeURIComponent(headers.name)
, value: ""
};

0 comments on commit 2518167

Please sign in to comment.