|
@@ -13,7 +13,7 @@ A project committed to make file acess and data transfer easier, effiecient for
|
13
|
13
|
* [About](#user-content-about)
|
14
|
14
|
* [Installation](#user-content-installation)
|
15
|
15
|
* [Recipes](#user-content-recipes)
|
16
|
|
-* HTTP Data Transfer
|
|
16
|
+* [HTTP Data Transfer](#user-content-http-data-transfer)
|
17
|
17
|
* [Regular Request](#user-content-regular-request)
|
18
|
18
|
* [Download file](#user-content-download-example--fetch-files-that-needs-authorization-token)
|
19
|
19
|
* [Upload file](#user-content-upload-example--dropbox-files-upload-api)
|
|
@@ -22,7 +22,7 @@ A project committed to make file acess and data transfer easier, effiecient for
|
22
|
22
|
* [Cancel HTTP request](#user-content-cancel-request)
|
23
|
23
|
* [Android Media Scanner, and Download Manager Support](#user-content-android-media-scanner-and-download-manager-support)
|
24
|
24
|
* [Self-Signed SSL Server](#user-content-self-signed-ssl-server)
|
25
|
|
-* File System
|
|
25
|
+* [File System](#user-content-file-system)
|
26
|
26
|
* [File access](#user-content-file-access)
|
27
|
27
|
* [File stream](#user-content-file-stream)
|
28
|
28
|
* [Manage cached files](#user-content-cache-file-management)
|
|
@@ -133,14 +133,23 @@ If you're using ES5 require statement to load the module, please add `default`.
|
133
|
133
|
var RNFetchBlob = require('react-native-fetch-blob').default
|
134
|
134
|
```
|
135
|
135
|
|
136
|
|
-#### Regular Request
|
|
136
|
+### HTTP Data Transfer
|
|
137
|
+
|
|
138
|
+---
|
137
|
139
|
|
138
|
|
-After `0.8.0` react-native-fetch-blob automatically decide how to send the body by checking `Content-Type` in header.
|
|
140
|
+#### Regular Request
|
139
|
141
|
|
140
|
|
-The rules are shown in the following diagram
|
|
142
|
+After `0.8.0` react-native-fetch-blob automatically decide how to send the body by checking its type and `Content-Type` in header. The rule is described in the following diagram
|
141
|
143
|
|
142
|
144
|
<img src="img/RNFB-flow (1).png" style="width : 90%" />
|
143
|
145
|
|
|
146
|
+To sum up :
|
|
147
|
+
|
|
148
|
+- If you're going to send a form data, the `Content-Type` header won't take effect if the body is an `Array` because we will set proper content type for you.
|
|
149
|
+- If you're going to send binary data, you have two choices, use BASE64 encoded string or a file path which points to a file contains the body. The `Content-Type` header does not matters.
|
|
150
|
+ - If the body is a BASE64 encoded string, the `Content-Type` header filed must containing substring`;BASE64` or `application/octet`
|
|
151
|
+ - If the body is a path point to a file, it must be a string starts with `RNFetchBlob-file://`, which can simply done by `RNFetchBlob.wrap(PATH_TO_THE_FILE)`
|
|
152
|
+- If you're going to send the body as-is, set a `Content-Type` header not containing `;BASE64` or `application/octet`.
|
144
|
153
|
|
145
|
154
|
#### Download example : Fetch files that needs authorization token
|
146
|
155
|
|
|
@@ -483,6 +492,8 @@ RNFetchBlob.config({
|
483
|
492
|
.then(...)
|
484
|
493
|
```
|
485
|
494
|
|
|
495
|
+### File System
|
|
496
|
+
|
486
|
497
|
#### File Access
|
487
|
498
|
|
488
|
499
|
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.
|
|
@@ -631,7 +642,7 @@ RNFetchBlob.config({
|
631
|
642
|
})
|
632
|
643
|
```
|
633
|
644
|
|
634
|
|
-#### Web API Polyfills
|
|
645
|
+### Web API Polyfills
|
635
|
646
|
|
636
|
647
|
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.
|
637
|
648
|
|