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
 
320
 
321
 #### Upload/Download progress
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
 ```js
325
 ```js
326
   RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
326
   RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
327
       ... some headers,
327
       ... some headers,
328
       'Content-Type' : 'octet-stream'
328
       'Content-Type' : 'octet-stream'
329
     }, base64DataString)
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
     .progress((received, total) => {
335
     .progress((received, total) => {
331
         console.log('progress', received / total)
336
         console.log('progress', received / total)
332
     })
337
     })
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
 #### Android Media Scanner, and Download Manager Support
363
 #### Android Media Scanner, and Download Manager Support
342
 
364
 
343
 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`.
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`.