|
@@ -1,4 +1,4 @@
|
1
|
|
-# react-native-fetch-blob [![npm](https://img.shields.io/npm/v/react-native-fetch-blob.svg?style=flat-square)](https://www.npmjs.com/package/react-native-fetch-blob) ![](https://img.shields.io/badge/PR-Welcome-brightgreen.svg?style=flat-square) [![npm](https://img.shields.io/npm/l/express.svg?maxAge=2592000&style=flat-square)]() [![npm](https://img.shields.io/badge/inProgress-0.7.0-yellow.svg?style=flat-square)](https://github.com/wkh237/react-native-fetch-blob/milestones)
|
|
1
|
+# react-native-fetch-blob ![release](https://img.shields.io/github/release/wkh237/react-native-fetch-blob.svg?maxAge=86400&style=flat-square) [![npm](https://img.shields.io/npm/v/react-native-fetch-blob.svg?style=flat-square)](https://www.npmjs.com/package/react-native-fetch-blob) ![](https://img.shields.io/badge/PR-Welcome-brightgreen.svg?style=flat-square) [![npm](https://img.shields.io/npm/l/express.svg?maxAge=2592000&style=flat-square)]() [![npm](https://img.shields.io/badge/inProgress-0.7.0-yellow.svg?style=flat-square)](https://github.com/wkh237/react-native-fetch-blob/milestones)
|
2
|
2
|
|
3
|
3
|
A module provides upload, download, and files access API. Supports file stream read/write for process large files.
|
4
|
4
|
|
|
@@ -44,11 +44,31 @@ Link package using [rnpm](https://github.com/rnpm/rnpm)
|
44
|
44
|
rnpm link
|
45
|
45
|
```
|
46
|
46
|
|
|
47
|
+### For React Native >= 0.29
|
|
48
|
+
|
|
49
|
+The Android application template has changed in [react-native@0.29](https://github.com/facebook/react-native/releases/tag/v0.29.0) our rnpm link script may not working properly, if you encounters some error, please follow these instructions, Thanks @dphov, also see related issue [#51](https://github.com/wkh237/react-native-fetch-blob/issues/51)
|
|
50
|
+
|
|
51
|
+Add this code to `MainApplication.java`
|
|
52
|
+
|
|
53
|
+```diff
|
|
54
|
+...
|
|
55
|
++ import com.RNFetchBlob.RNFetchBlobPackage;
|
|
56
|
+...
|
|
57
|
+protected List<ReactPackage> getPackages() {
|
|
58
|
+ return Arrays.<ReactPackage>asList(
|
|
59
|
+ new MainReactPackage(),
|
|
60
|
++ new RNFetchBlobPackage()
|
|
61
|
+ );
|
|
62
|
+ }
|
|
63
|
+ };
|
|
64
|
+...
|
|
65
|
+```
|
|
66
|
+
|
47
|
67
|
**Grant Permission to External storage for Android 5.0 or lower**
|
48
|
68
|
|
49
|
|
-Mechanism about granting Android permissions has slightly different since Android 6.0 released, please refer to [Officail Document](https://developer.android.com/training/permissions/requesting.html).
|
|
69
|
+Mechanism about granting Android permissions has slightly different since Android 6.0 released, please refer to [Official Document](https://developer.android.com/training/permissions/requesting.html).
|
50
|
70
|
|
51
|
|
-If you're going to access external storage (say, SD card storage) for `Android 5.0` (or lower) devices, you might have to add the following line to `AndroidManifetst.xml`.
|
|
71
|
+If you're going to access external storage (say, SD card storage) for `Android 5.0` (or lower) devices, you might have to add the following line to `AndroidManifest.xml`.
|
52
|
72
|
|
53
|
73
|
```diff
|
54
|
74
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
@@ -110,7 +130,7 @@ RNFetchBlob.fetch('GET', 'http://www.example.com/images/img1.png', {
|
110
|
130
|
|
111
|
131
|
#### Download to storage directly
|
112
|
132
|
|
113
|
|
-The simplest way is give a `fileCach` option to config, and set it to `true`. This will let the incoming response data stored in a temporary path **wihout** any file extension.
|
|
133
|
+The simplest way is give a `fileCache` option to config, and set it to `true`. This will let the incoming response data stored in a temporary path **without** any file extension.
|
114
|
134
|
|
115
|
135
|
**These files won't be removed automatically, please refer to [Cache File Management](#user-content-cache-file-management)**
|
116
|
136
|
|
|
@@ -149,7 +169,7 @@ RNFetchBlob
|
149
|
169
|
console.log('The file saved to ', res.path())
|
150
|
170
|
// Beware that when using a file path as Image source on Android,
|
151
|
171
|
// you must prepend "file://"" before the file path
|
152
|
|
- imageView = <Image source={{ uri : Platform.OS === 'android' ? 'file://' : '' + res.path() }}/>
|
|
172
|
+ imageView = <Image source={{ uri : Platform.OS === 'android' ? 'file://' + res.path() : '' + res.path() }}/>
|
153
|
173
|
})
|
154
|
174
|
```
|
155
|
175
|
|
|
@@ -297,7 +317,7 @@ What if you want to upload a file in some field ? Just like [upload a file from
|
297
|
317
|
|
298
|
318
|
#### Upload/Download progress
|
299
|
319
|
|
300
|
|
-In `version >= 0.4.2` it is possible to know the upload/download progress. On Anroid, only download progress is supported. See [wiki](https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API#fetchprogresseventlistenerpromisernfetchblobresponse) for more information.
|
|
320
|
+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.
|
301
|
321
|
|
302
|
322
|
```js
|
303
|
323
|
RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
|
|
@@ -401,7 +421,7 @@ RNFetchBlob.config({
|
401
|
421
|
|
402
|
422
|
File access APIs were made when developing `v0.5.0`, which helping us write tests, and was not planned to be a part of this module. However we realized that, it's hard to find a great solution to manage cached files, every one who use this moudle may need these APIs for there cases.
|
403
|
423
|
|
404
|
|
-Before get started using file APIs we recommend read [Differences between File Source](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#differences-between-file-source) first.
|
|
424
|
+Before start using file APIs, we recommend read [Differences between File Source](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#differences-between-file-source) first.
|
405
|
425
|
|
406
|
426
|
File Access APIs
|
407
|
427
|
- [asset (0.6.2)](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#assetfilenamestringstring)
|