|
1 | 1 | # react-native-fetch-blob
|
2 | 2 | [](https://github.com/wkh237/react-native-fetch-blob/releases) [](https://www.npmjs.com/package/react-native-fetch-blob)  [](https://github.com/wkh237/react-native-fetch-blob/wiki) []()
|
3 | 3 |
|
4 |
| - |
5 | 4 | A project committed to make file acess and data transfer easier, efficient for React Native developers.
|
6 | 5 |
|
7 |
| -# [Please visit our Github Page for latest document](https://github.com/wkh237/react-native-fetch-blob) |
8 |
| - |
9 | 6 | ## Features
|
10 | 7 | - Transfer data directly from/to storage without BASE64 bridging
|
11 | 8 | - File API supports normal files, Asset files, and CameraRoll files
|
@@ -403,6 +400,30 @@ In `version >= 0.4.2` it is possible to know the upload/download progress. After
|
403 | 400 | })
|
404 | 401 | ```
|
405 | 402 |
|
| 403 | +In `0.9.6`, you can specify an optional first argument which contains `count` and `interval` to limit progress event frequency (this will be done in native context in order to reduce RCT bridge overhead). Notice that `count` argument will not work if the server does not provide response content length. |
| 404 | + |
| 405 | + |
| 406 | +```js |
| 407 | + RNFetchBlob.fetch('POST', 'http://www.example.com/upload', { |
| 408 | + ... some headers, |
| 409 | + 'Content-Type' : 'octet-stream' |
| 410 | + }, base64DataString) |
| 411 | + // listen to upload progress event, emit every 250ms |
| 412 | + .uploadProgress({ interval : 250 },(written, total) => { |
| 413 | + console.log('uploaded', written / total) |
| 414 | + }) |
| 415 | + // listen to download progress event, every 10% |
| 416 | + .progress({ count : 10 }, (received, total) => { |
| 417 | + console.log('progress', received / total) |
| 418 | + }) |
| 419 | + .then((resp) => { |
| 420 | + // ... |
| 421 | + }) |
| 422 | + .catch((err) => { |
| 423 | + // ... |
| 424 | + }) |
| 425 | +``` |
| 426 | + |
406 | 427 | ### Cancel Request
|
407 | 428 |
|
408 | 429 | After `0.7.0` it is possible to cancel a HTTP request. When the request cancel, it will definately throws an promise rejection, be sure to catch it.
|
|
0 commit comments