You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 16, 2019. It is now read-only.
*[RNFetchBlob as Fetch](#user-content-rnfetchblob-as-fetch)
27
28
*[File System](#user-content-file-system)
28
29
*[File access](#user-content-file-access)
29
30
*[File stream](#user-content-file-stream)
@@ -40,6 +41,7 @@ This project was initially for solving the issue [facebook/react-native#854](htt
40
41
41
42
In `0.8.0` we introduced experimential Web API polyfills that make it possible to use browser-based libraries in React Native, for example, [FireBase JS SDK](https://github.com/wkh237/rn-firebase-storage-upload-sample)
42
43
44
+
43
45
## Installation
44
46
45
47
Install package from npm
@@ -63,7 +65,7 @@ Open `android/settings.gradle`, and add these lines which will app RNFetchBlob A
63
65
```diff
64
66
include ':app'
65
67
+ include ':react-native-fetch-blob'
66
-
+ project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir,' ../node_modules/react-native-fetch-blob/android')
68
+
+ project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')
67
69
```
68
70
69
71
Add this line to `MainApplication.java`, so that RNFetchBlob package becomes part of react native package.
@@ -118,7 +120,7 @@ Also, if you're going to use `Android Download Manager` you have to add this to
118
120
119
121
Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app. So adding permissions in `AndroidManifest.xml` won't work in Android 6.0 devices. To grant permissions in runtime, you might use modules like [react-native-android-permissions](https://github.com/lucasferreira/react-native-android-permissions).
120
122
121
-
## Recipes
123
+
## Usage
122
124
123
125
ES6
124
126
@@ -332,7 +334,7 @@ Elements have property `filename` will be transformed into binary format, otherw
332
334
})
333
335
```
334
336
335
-
What if you want to upload a file in some field ? Just like [upload a file from storage](#user-content-upload-a-file-from-storage) example, wrap `data` by `wrap` API (this feature is only available for `version >= v0.5.0`). On version >= `0.6.2`, it is possible to set custom MIME type when appending file to form data.
337
+
What if you want to upload a file using form data ? Just like [upload a file from storage](#user-content-upload-a-file-from-storage) example, wrap `data` by `wrap` API (this feature is only available for `version >= v0.5.0`). On version >= `0.6.2`, it is possible to set custom MIME type when appending file to form data.
#### Android Media Scanner, and Download Manager Support
418
+
### RNFetchBlob as Fetch
419
+
420
+
0.9.0
421
+
422
+
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.
423
+
424
+
[See document and examples](https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API#fetch-replacement)
425
+
426
+
### Android Media Scanner, and Download Manager Support
417
427
418
428
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`.
419
429
@@ -495,6 +505,38 @@ RNFetchBlob.config({
495
505
.then(...)
496
506
```
497
507
508
+
**Open Downloaded File with Intent**
509
+
510
+
This is a new feature added in `0.9.0`, if you're going to open a file path using official [Linking](https://facebook.github.io/react-native/docs/linking.html) API that might not work as expected, also, if you're going to install an APK in `Downloads` app, that will not work too. As an alternative, you can try `actionViewIntent` API, which will send an ACTION_VIEW intent for you which uses the given `MIME` type.
After `0.8.0` we've made some [Web API polyfills](https://github.com/wkh237/react-native-fetch-blob/wiki/Web-API-Polyfills-(work-in-progress)) that makes some browser-based library available in RN.
692
+
After `0.8.0` we've made some [Web API polyfills](https://github.com/wkh237/react-native-fetch-blob/wiki/Web-API-Polyfills-(experimental)) that makes some browser-based library available in RN.
651
693
652
694
- Blob
653
695
- XMLHttpRequest (Use our implementation if you're going to use it with Blob)
654
696
697
+
Here's a [sample app](https://github.com/wkh237/rn-firebase-storage-upload-sample) that uses polyfills to upload files to FireBase.
698
+
655
699
### Performance Tips
656
700
657
701
---
658
702
659
-
**Reduce RCT Bridge Overhead and BASE64 Time**
703
+
**Reduce RCT Bridge and BASE64 Overheard**
660
704
661
705
React Native connects JS and Native context by passing JSON through React bridge, therefore there will be an overhead to convert data before they sent. When data is large, this will be quite a performance impact to your app, it's recommended to use file storage instead of BASE64 if possible. The following chart shows how much faster when loading data from storage than BASE64 encoded string on iphone 6.
662
706
@@ -678,7 +722,7 @@ If you're going to concatenate files, you don't have to read the data to JS cont
| 0.9.0| Fix unicode response data format issue #73. Improve Android performance by using thread pool instead of async task. Add Fetch replacement #70. Add Android only API `actionViewIntent` to open file or install APK in app|
682
726
| 0.8.1 | Remove Web API log and fix ios progress report function. |
683
727
| 0.8.0 | Added Web API polyfills, support regular request, added timeout option. |
684
728
| 0.7.5 | Fix installation script that make it compatible to react-native < 0.28 |
0 commit comments