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.
A project committed to making file access and data transfer easier, efficient for React Native developers.
6
-
7
-
> If you're going to use GitHub repo as npm dependency, please visit the [archive repository](https://github.com/wkh237/react-native-fetch-blob-package/releases/tag/v0.9.6).
8
-
9
-
> For Firebase Storage solution, please upgrade to latest version for best compatibility.
5
+
A project committed to making file access and data transfer easier and more efficient for React Native developers.
6
+
> For Firebase Storage solution, please upgrade to the latest version for the best compatibility.
10
7
11
8
## Features
12
9
- Transfer data directly from/to storage without BASE64 bridging
@@ -16,7 +13,7 @@ A project committed to making file access and data transfer easier, efficient fo
16
13
- Blob, File, XMLHttpRequest polyfills that make browser-based library available in RN (experimental)
17
14
- JSON stream supported base on [Oboe.js](https://github.com/jimhigson/oboe.js/)@jimhigson
18
15
19
-
## TOC
16
+
## TOC (visit [Wiki](https://github.com/wkh237/react-native-fetch-blob/wiki) to get the complete documentation)
20
17
*[About](#user-content-about)
21
18
*[Installation](#user-content-installation)
22
19
*[HTTP Data Transfer](#user-content-http-data-transfer)
@@ -35,15 +32,16 @@ A project committed to making file access and data transfer easier, efficient fo
This project was initially for solving the issue [facebook/react-native#854](https://github.com/facebook/react-native/issues/854) because React Native lack of `Blob` implementation and it's problematic when transferring binary data. Now the project is committed to making file access and transfer easier, efficient for React Native developers.
46
-
We've implemented highly customizable filesystem and network module which plays well together. For example, upload and download data directly from/to storage which is much more efficient in some cases(especially for large ones). The file system supports file stream, so you don't have to worry about OOM problem when accessing large files.
42
+
This project was started in the cause of solving issue [facebook/react-native#854](https://github.com/facebook/react-native/issues/854), React Native's lacks of `Blob` implementation which results into problems when transferring binary data.
43
+
44
+
It is committed to making file access and transfer easier and more efficient for React Native developers. We've implemented highly customizable filesystem and network module which plays well together. For example, developers can upload and download data directly from/to storage, which is more efficient, especially for large files. The file system supports file stream, so you don't have to worry about OOM problem when accessing large files.
47
45
48
46
In `0.8.0` we introduced experimental Web API polyfills that make it possible to use browser-based libraries in React Native, such as, [FireBase JS SDK](https://github.com/wkh237/rn-firebase-storage-upload-sample)
49
47
@@ -56,16 +54,22 @@ Install package from npm
56
54
npm install --save react-native-fetch-blob
57
55
```
58
56
59
-
Or if using CocoaPods, add the pod to your `Podfile`, for example:
57
+
Or if using CocoaPods, add the pod to your `Podfile`
For 0.29.2+ projects, simply link native packages via the following command because rnpm has been merged into react-native, you no longer need it.
72
+
For 0.29.2+ projects, simply link native packages via the following command (note: rnpm has been merged into react-native)
69
73
70
74
```
71
75
react-native link
@@ -112,7 +116,7 @@ If you're going to access external storage (say, SD card storage) for `Android 5
112
116
113
117
```
114
118
115
-
Also, if you're going to use `Android Download Manager` you have to add this to `AndroidManifetst.xml`
119
+
Also, if you're going to use `Android Download Manager` you have to add this to `AndroidManifest.xml`
116
120
117
121
```diff
118
122
<intent-filter>
@@ -149,9 +153,9 @@ var RNFetchBlob = require('react-native-fetch-blob').default
149
153
150
154
### Regular Request
151
155
152
-
After `0.8.0` react-native-fetch-blob automatically decide how to send the body by checking its type and `Content-Type` in the header. The rule is described in the following diagram
156
+
After `0.8.0` react-native-fetch-blob automatically decides how to send the body by checking its type and `Content-Type` in the header. The rule is described in the following diagram
If you prefer a particular file path rather than randomly generated one, you can use `path` option. We've added [several constants](#user-content-dirs) in v0.5.0 which represents commonly used directories.
245
+
If you prefer a particular file path rather than randomly generated one, you can use `path` option. We've added [several constants](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#dirs) in v0.5.0 which represents commonly used directories.
242
246
243
247
```js
244
248
let dirs =RNFetchBlob.fs.dirs
@@ -529,7 +533,9 @@ When downloading large files on Android it is recommended to use `Download Manag
529
533
530
534
<imgsrc="img/download-manager.png"width="256">
531
535
532
-
When using DownloadManager, `fileCache` and `path` properties in `config` will not take effect, because Android DownloadManager can only store files to external storage. When download complete, DownloadManager will generate a file path so that you can deal with it.
536
+
When using DownloadManager, `fileCache` and `path` properties in `config` will not take effect, because Android DownloadManager can only store files to external storage, also notice that Download Manager can only support `GET` method, which means the request body will be ignored.
537
+
538
+
When download complete, DownloadManager will generate a file path so that you can deal with it.
533
539
534
540
```js
535
541
RNFetchBlob
@@ -551,6 +557,7 @@ RNFetchBlob
551
557
})
552
558
```
553
559
560
+
Your app might not have right to remove/change the file created by Download Manager, therefore you might need to [set custom location to the download task](https://github.com/wkh237/react-native-fetch-blob/issues/236).
554
561
555
562
**Download Notification and Visibility in Download App (Android Only)**
556
563
@@ -806,7 +813,7 @@ If you're going to concatenate files, you don't have to read the data to JS cont
806
813
## Caveats
807
814
808
815
* This library does not urlencode unicode characters in URL automatically, see [#146](https://github.com/wkh237/react-native-fetch-blob/issues/146).
809
-
* When a `Blob` , from existing file, the file **WILL BE REMOVE** if you `close` the blob.
816
+
* When you create a `Blob` , from an existing file, the file **WILL BE REMOVED** if you `close` the blob.
810
817
* If you replaced `window.XMLHttpRequest` for some reason (e.g. make Firebase SDK work), it will also affect how official `fetch` works (basically it should work just fine).
811
818
* When file stream and upload/download progress event slow down your app, consider an upgrade to `0.9.6+`, use [additional arguments](https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API#fetchprogressconfig-eventlistenerpromisernfetchblobresponse) to limit its frequency.
812
819
* When passing a file path to the library, remove `file://` prefix.
@@ -294,7 +296,8 @@ public void readStream(String path, String encoding, int bufferSize, int tick, f
294
296
buffer = null;
295
297
296
298
} catch (Exceptionerr) {
297
-
emitStreamEvent(streamId, "error", "Failed to convert data to "+encoding+" encoded string, this might due to the source data is not able to convert using this encoding.");
299
+
emitStreamEvent(streamId, "warn", "Failed to convert data to "+encoding+" encoded string, this might due to the source data is not able to convert using this encoding.");
0 commit comments