@@ -16,30 +16,34 @@ Sorry, this isn't ready for you yet.
1616In this example we are constructor a form with 3 fields that contain a string,
1717a buffer and a file stream.
1818
19- var FormData = require('form-data');
20- var fs = require('fs');
19+ ``` javascript
20+ var FormData = require (' form-data' );
21+ var fs = require (' fs' );
2122
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'));
23+ var form = new FormData ();
24+ form .append (' my_field' , ' my value' );
25+ form .append (' my_buffer' , new Buffer (10 ));
26+ form .append (' my_file' , fs .createReadStream (' /foo/bar.jpg' ));
27+ ```
2628
2729In order to submit this form to a web application, you can use node's http
2830client interface:
2931
30- var http = require('http');
32+ ``` javascript
33+ var http = require (' http' );
3134
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- });
35+ var request = http .request ({
36+ method: ' post' ,
37+ host: ' example.org' ,
38+ path: ' /upload' ,
39+ headers: {' Content-Type' : ' application/x-www-form-urlencoded' }
40+ });
3841
39- form.pipe(request);
42+ form .pipe (request);
4043
41- request.on('response, function(res) {
42- console.log(res.statusCode);
43- });
44+ request .on (' response, function(res) {
45+ console.log(res.statusCode);
46+ });
47+ ```
4448
4549[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
0 commit comments