Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 4974522

Browse files
authored
Update README.md
1 parent 9e33390 commit 4974522

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,18 @@ What if you want to upload a file in some field ? Just like [upload a file from
320320

321321
#### Upload/Download progress
322322

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.
324324

325325
```js
326326
RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
327327
... some headers,
328328
'Content-Type' : 'octet-stream'
329329
}, base64DataString)
330+
// listen to upload progress event
331+
.uploadProgress((written, total) => {
332+
console.log('uploaded', written / total)
333+
})
334+
// listen to download progress event
330335
.progress((received, total) => {
331336
console.log('progress', received / total)
332337
})
@@ -338,6 +343,23 @@ In `version >= 0.4.2` it is possible to know the upload/download progress. On An
338343
})
339344
```
340345

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+
341363
#### Android Media Scanner, and Download Manager Support
342364

343365
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`.

0 commit comments

Comments
 (0)