Ver código fonte

Update README.md

wkh237 7 anos atrás
pai
commit
a9cf7a2843
1 arquivos alterados com 25 adições e 1 exclusões
  1. 25
    1
      README.md

+ 25
- 1
README.md Ver arquivo

380
 
380
 
381
 ### Upload/Download progress
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
 ```js
385
 ```js
386
   RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
386
   RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
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
 ### Cancel Request
430
 ### Cancel Request
407
 
431
 
408
 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.
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.