|
@@ -1,11 +1,8 @@
|
1
|
1
|
# react-native-fetch-blob
|
2
|
2
|
[![release](https://img.shields.io/github/release/wkh237/react-native-fetch-blob.svg?style=flat-square)](https://github.com/wkh237/react-native-fetch-blob/releases) [![npm](https://img.shields.io/npm/v/react-native-fetch-blob.svg?style=flat-square)](https://www.npmjs.com/package/react-native-fetch-blob) ![](https://img.shields.io/badge/PR-Welcome-brightgreen.svg?style=flat-square) [![](https://img.shields.io/badge/Wiki-Public-brightgreen.svg?style=flat-square)](https://github.com/wkh237/react-native-fetch-blob/wiki) [![npm](https://img.shields.io/npm/l/react-native-fetch-blob.svg?maxAge=2592000&style=flat-square)]()
|
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.
|