Browse Source

Update README.md

wkh237 8 years ago
parent
commit
4974522beb
1 changed files with 23 additions and 1 deletions
  1. 23
    1
      README.md

+ 23
- 1
README.md View File

@@ -320,13 +320,18 @@ What if you want to upload a file in some field ? Just like [upload a file from
320 320
 
321 321
 #### Upload/Download progress
322 322
 
323
-In `version >= 0.4.2` it is possible to know the upload/download progress. On Android, only download progress is supported. See [wiki](https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API#fetchprogresseventlistenerpromisernfetchblobresponse) for more information.
323
+In `version >= 0.4.2` it is possible to know the upload/download progress. After `0.7.0` IOS and Android upload progress are supported.
324 324
 
325 325
 ```js
326 326
   RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
327 327
       ... some headers,
328 328
       'Content-Type' : 'octet-stream'
329 329
     }, base64DataString)
330
+    // listen to upload progress event
331
+    .uploadProgress((written, total) => {
332
+        console.log('uploaded', written / total)
333
+    })
334
+    // listen to download progress event
330 335
     .progress((received, total) => {
331 336
         console.log('progress', received / total)
332 337
     })
@@ -338,6 +343,23 @@ In `version >= 0.4.2` it is possible to know the upload/download progress. On An
338 343
     })
339 344
 ```
340 345
 
346
+#### Cancel Request
347
+
348
+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.
349
+
350
+```js
351
+let task = RNFetchBlob.fetch('GET', 'http://example.com/file/1')
352
+
353
+task.then(() => { ... })
354
+    // handle request cancelled rejection
355
+    .catch((err) => {
356
+        console.log(err)
357
+    })
358
+// cancel the request, the callback function is optional
359
+task.cancel((err) => { ... })
360
+
361
+```
362
+
341 363
 #### Android Media Scanner, and Download Manager Support
342 364
 
343 365
 If you want to make a file in `External Storage` becomes visible in Picture, Downloads, or other built-in apps, you will have to use `Media Scanner` or `Download Manager`.