|
|
|
|
26
|
* [Android Media Scanner, and Download Manager Support](#user-content-android-media-scanner-and-download-manager-support)
|
26
|
* [Android Media Scanner, and Download Manager Support](#user-content-android-media-scanner-and-download-manager-support)
|
27
|
* [Self-Signed SSL Server](#user-content-self-signed-ssl-server)
|
27
|
* [Self-Signed SSL Server](#user-content-self-signed-ssl-server)
|
28
|
* [Transfer Encoding](#user-content-transfer-encoding)
|
28
|
* [Transfer Encoding](#user-content-transfer-encoding)
|
29
|
- * [RNFetchBlob as Fetch](#user-content-rnfetchblob-as-fetch)
|
|
|
|
|
29
|
+ * [Drop-in Fetch Replacement](#user-content-drop-in-fetch-replacement)
|
30
|
* [File System](#user-content-file-system)
|
30
|
* [File System](#user-content-file-system)
|
31
|
* [File access](#user-content-file-access)
|
31
|
* [File access](#user-content-file-access)
|
32
|
* [File stream](#user-content-file-stream)
|
32
|
* [File stream](#user-content-file-stream)
|
33
|
* [Manage cached files](#user-content-cache-file-management)
|
33
|
* [Manage cached files](#user-content-cache-file-management)
|
34
|
* [Web API Polyfills](#user-content-web-api-polyfills)
|
34
|
* [Web API Polyfills](#user-content-web-api-polyfills)
|
35
|
-* [Performance Tips](#user-content-performance-tipsd)
|
|
|
|
|
35
|
+* [Performance Tips](#user-content-performance-tips)
|
36
|
* [API References](https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API)
|
36
|
* [API References](https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API)
|
37
|
* [Caveats](#user-content-caveats)
|
37
|
* [Caveats](#user-content-caveats)
|
38
|
* [Development](#user-content-development)
|
38
|
* [Development](#user-content-development)
|
|
|
|
|
452
|
|
452
|
|
453
|
```
|
453
|
```
|
454
|
|
454
|
|
455
|
-### RNFetchBlob as Fetch
|
|
|
|
|
455
|
+### Drop-in Fetch Replacement
|
456
|
|
456
|
|
457
|
0.9.0
|
457
|
0.9.0
|
458
|
|
458
|
|
459
|
-If you have existing code that uses `whatwg-fetch`(the official **fetch**), you don't have to change them after 0.9.0, just use fetch replacement. The difference between Official fetch and fetch replacement is, official fetch uses [whatwg-fetch](https://github.com/github/fetch) js library which wraps XMLHttpRequest polyfill under the hood it's a great library for web developers, however that does not play very well with RN. Our implementation is simply a wrapper of RNFetchBlob.fetch and fs APIs, so you can access all the features we provide.
|
|
|
|
|
459
|
+If you have existing code that uses `whatwg-fetch`(the official **fetch**), it's not necessary to replace them with `RNFetchblob.fetch`, you can simply use our **Fetch Replacement**. The difference between Official them is official fetch uses [whatwg-fetch](https://github.com/github/fetch) which wraps XMLHttpRequest polyfill under the hood. It's a great library for web developers, but does not play very well with RN. Our implementation is simply a wrapper of our `fetch` and `fs` APIs, so you can access all the features we provided.
|
460
|
|
460
|
|
461
|
[See document and examples](https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API#fetch-replacement)
|
461
|
[See document and examples](https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API#fetch-replacement)
|
462
|
|
462
|
|
|
|
|
|
613
|
|
613
|
|
614
|
When calling `readStream` method, you have to `open` the stream, and start to read data. When the file is large, consider using an appropriate `bufferSize` and `interval` to reduce the native event dispatching overhead (see [Performance Tips](#user-content-performance-tips))
|
614
|
When calling `readStream` method, you have to `open` the stream, and start to read data. When the file is large, consider using an appropriate `bufferSize` and `interval` to reduce the native event dispatching overhead (see [Performance Tips](#user-content-performance-tips))
|
615
|
|
615
|
|
|
|
616
|
+> The file stream event has a default throttle(10ms) and buffer size which preventing it cause too much overhead to main thread, yo can also [tweak these values](#user-content-performance-tips).
|
|
|
617
|
+
|
616
|
```js
|
618
|
```js
|
617
|
let data = ''
|
619
|
let data = ''
|
618
|
RNFetchBlob.fs.readStream(
|
620
|
RNFetchBlob.fs.readStream(
|