Skip to content

Commit de8f441

Browse files
committed
Updated Readme.md
- travis badge - install instructions (#23) - custom filename/contentType example - todo, license (#14)
1 parent 850ba1b commit de8f441

1 file changed

Lines changed: 32 additions & 4 deletions

File tree

Readme.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# form-data
1+
# Form-Data [![Build Status](https://travis-ci.org/alexindigo/node-form-data.png?branch=master)](https://travis-ci.org/alexindigo/node-form-data)
22

33
A module to create readable `"multipart/form-data"` streams. Can be used to
44
submit forms and file uploads to other web applications.
@@ -10,7 +10,9 @@ The API of this module is inspired by the
1010

1111
## Install
1212

13-
Sorry, this isn't ready for you yet.
13+
```
14+
npm install form-data
15+
```
1416

1517
## Usage
1618

@@ -102,7 +104,28 @@ form.submit('http://example.com/', function(err, res) {
102104
});
103105
```
104106

105-
For edge cases, like POST request to URL with query string or to pass HTTP auth creadentials, object can be passed to `form.submit()` as first parameter:
107+
Form-Data can recognize and fetch all the required information from common types of streams (fs.readStream, http.response and mikeal's request), for some other types of streams you'd need to provide "file"-related information manually:
108+
109+
``` javascript
110+
someModule.stream(function(err, stdout, stderr) {
111+
if (err) throw err;
112+
113+
var form = new FormData();
114+
115+
form.append('file', stdout, {
116+
filename: 'unicycle.jpg',
117+
contentType: 'image/jpg',
118+
knownLength: 19806
119+
});
120+
121+
form.submit('http://example.com/', function(err, res) {
122+
if (err) throw err;
123+
console.log('Done');
124+
});
125+
});
126+
```
127+
128+
For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter:
106129

107130
``` javascript
108131
form.submit({
@@ -114,5 +137,10 @@ form.submit({
114137
});
115138
```
116139

140+
## TODO
117141

118-
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
142+
- Add new streams (0.10) support and try really hard not to break it for 0.8.x.
143+
144+
## License
145+
146+
Form-Data is licensed under the MIT license.

0 commit comments

Comments
 (0)