File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments