|
@@ -380,7 +380,7 @@ What if you want to append a file to form data ? Just like [upload a file from s
|
380
|
380
|
|
381
|
381
|
### Upload/Download progress
|
382
|
382
|
|
383
|
|
-In `version >= 0.4.2` it is possible to know the upload/download progress. After `0.7.0` IOS and Android upload progress are also supported.
|
|
383
|
+In `version >= 0.4.2` it is possible to know the upload/download progress. After `0.7.0` IOS and Android upload progress are also supported.
|
384
|
384
|
|
385
|
385
|
```js
|
386
|
386
|
RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
|
|
@@ -403,6 +403,30 @@ In `version >= 0.4.2` it is possible to know the upload/download progress. After
|
403
|
403
|
})
|
404
|
404
|
```
|
405
|
405
|
|
|
406
|
+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.
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+```js
|
|
410
|
+ RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
|
|
411
|
+ ... some headers,
|
|
412
|
+ 'Content-Type' : 'octet-stream'
|
|
413
|
+ }, base64DataString)
|
|
414
|
+ // listen to upload progress event, emit every 250ms
|
|
415
|
+ .uploadProgress({ interval : 250 },(written, total) => {
|
|
416
|
+ console.log('uploaded', written / total)
|
|
417
|
+ })
|
|
418
|
+ // listen to download progress event, every 10%
|
|
419
|
+ .progress({ count : 10 }, (received, total) => {
|
|
420
|
+ console.log('progress', received / total)
|
|
421
|
+ })
|
|
422
|
+ .then((resp) => {
|
|
423
|
+ // ...
|
|
424
|
+ })
|
|
425
|
+ .catch((err) => {
|
|
426
|
+ // ...
|
|
427
|
+ })
|
|
428
|
+```
|
|
429
|
+
|
406
|
430
|
### Cancel Request
|
407
|
431
|
|
408
|
432
|
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.
|