Skip to content

Commit 8c744e5

Browse files
committed
Initial Readme and package.json
0 parents  commit 8c744e5

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

Readme.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# form-data
2+
3+
A module to create readable `"application/x-www-form-urlencoded"` streams. Can be used to submit forms and file uploads to other web applications.
4+
5+
The API of this module is inspired by the
6+
[XMLHttpRequest-2 FormData Interface][xhr2-fd].
7+
8+
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
9+
10+
## Install
11+
12+
Sorry, this isn't ready for you yet.
13+
14+
## Usage
15+
16+
In this example we are constructor a form with 3 fields that contain a string,
17+
a buffer and a file stream.
18+
19+
var FormData = require('form-data');
20+
var fs = require('fs');
21+
22+
var form = new FormData();
23+
form.append('my_field', 'my value');
24+
form.append('my_buffer', new Buffer(10));
25+
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
26+
27+
In order to submit this form to a web application, you can use node's http
28+
client interface:
29+
30+
var http = require('http');
31+
32+
var request = http.request({
33+
method: 'post',
34+
host: 'example.org',
35+
path: '/upload',
36+
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
37+
});
38+
39+
form.pipe(request);
40+
41+
request.on('response, function(res) {
42+
console.log(res.statusCode);
43+
});
44+
45+
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"author": "Felix Geisendörfer <[email protected]> (http://debuggable.com/)",
3+
"name": "form-data",
4+
"description": "A module to create readable `\"application/x-www-form-urlencoded\"` streams. Can be used to submit forms and file uploads to other web applications.",
5+
"version": "0.0.0",
6+
"repository": {
7+
"type": "git",
8+
"url": "git://github.com/felixge/form-data.git"
9+
},
10+
"main": "./lib/form_data",
11+
"engines": {
12+
"node": "*"
13+
},
14+
"dependencies": {},
15+
"devDependencies": {}
16+
}

0 commit comments

Comments
 (0)