modif comtabilite
This commit is contained in:
+23
-6
@@ -6,11 +6,11 @@ The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface]
|
||||
|
||||
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
|
||||
|
||||
[](https://travis-ci.org/form-data/form-data)
|
||||
[](https://travis-ci.org/form-data/form-data)
|
||||
[](https://ci.appveyor.com/project/alexindigo/form-data)
|
||||
[](https://travis-ci.org/form-data/form-data)
|
||||
[](https://travis-ci.org/form-data/form-data)
|
||||
[](https://ci.appveyor.com/project/alexindigo/form-data)
|
||||
|
||||
[](https://coveralls.io/github/form-data/form-data?branch=master)
|
||||
[](https://coveralls.io/github/form-data/form-data?branch=master)
|
||||
[](https://david-dm.org/form-data/form-data)
|
||||
[](https://www.bithound.io/github/form-data/form-data)
|
||||
|
||||
@@ -75,6 +75,20 @@ form.submit('http://example.org/', function(err, res) {
|
||||
|
||||
For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods.
|
||||
|
||||
### Custom options
|
||||
|
||||
You can provide custom options, such as `maxDataSize`:
|
||||
|
||||
``` javascript
|
||||
var FormData = require('form-data');
|
||||
|
||||
var form = new FormData({ maxDataSize: 20971520 });
|
||||
form.append('my_field', 'my value');
|
||||
form.append('my_buffer', /* something big */);
|
||||
```
|
||||
|
||||
List of available options could be found in [combined-stream](https://github.com/felixge/node-combined-stream/blob/master/lib/combined_stream.js#L7-L15)
|
||||
|
||||
### Alternative submission methods
|
||||
|
||||
You can use node's http client interface:
|
||||
@@ -132,8 +146,9 @@ someModule.stream(function(err, stdout, stderr) {
|
||||
var form = new FormData();
|
||||
|
||||
form.append('file', stdout, {
|
||||
filename: 'unicycle.jpg',
|
||||
contentType: 'image/jpg',
|
||||
filename: 'unicycle.jpg', // ... or:
|
||||
filepath: 'photos/toys/unicycle.jpg',
|
||||
contentType: 'image/jpeg',
|
||||
knownLength: 19806
|
||||
});
|
||||
|
||||
@@ -144,6 +159,8 @@ someModule.stream(function(err, stdout, stderr) {
|
||||
});
|
||||
```
|
||||
|
||||
The `filepath` property overrides `filename` and may contain a relative path. This is typically used when uploading [multiple files from a directory](https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory).
|
||||
|
||||
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:
|
||||
|
||||
``` javascript
|
||||
|
||||
Reference in New Issue
Block a user