Browse Source

Update README.md

wkh237 8 years ago
parent
commit
ec47aaf836
1 changed files with 17 additions and 6 deletions
  1. 17
    6
      README.md

+ 17
- 6
README.md View File

13
 * [About](#user-content-about)
13
 * [About](#user-content-about)
14
 * [Installation](#user-content-installation)
14
 * [Installation](#user-content-installation)
15
 * [Recipes](#user-content-recipes)
15
 * [Recipes](#user-content-recipes)
16
-* HTTP Data Transfer
16
+* [HTTP Data Transfer](#user-content-http-data-transfer)
17
  * [Regular Request](#user-content-regular-request)
17
  * [Regular Request](#user-content-regular-request)
18
  * [Download file](#user-content-download-example--fetch-files-that-needs-authorization-token)
18
  * [Download file](#user-content-download-example--fetch-files-that-needs-authorization-token)
19
  * [Upload file](#user-content-upload-example--dropbox-files-upload-api)
19
  * [Upload file](#user-content-upload-example--dropbox-files-upload-api)
22
  * [Cancel HTTP request](#user-content-cancel-request)
22
  * [Cancel HTTP request](#user-content-cancel-request)
23
  * [Android Media Scanner, and Download Manager Support](#user-content-android-media-scanner-and-download-manager-support)
23
  * [Android Media Scanner, and Download Manager Support](#user-content-android-media-scanner-and-download-manager-support)
24
  * [Self-Signed SSL Server](#user-content-self-signed-ssl-server)
24
  * [Self-Signed SSL Server](#user-content-self-signed-ssl-server)
25
-* File System
25
+* [File System](#user-content-file-system)
26
  * [File access](#user-content-file-access)
26
  * [File access](#user-content-file-access)
27
  * [File stream](#user-content-file-stream)
27
  * [File stream](#user-content-file-stream)
28
  * [Manage cached files](#user-content-cache-file-management)
28
  * [Manage cached files](#user-content-cache-file-management)
133
 var RNFetchBlob = require('react-native-fetch-blob').default
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
 <img src="img/RNFB-flow (1).png" style="width : 90%" />
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
 #### Download example : Fetch files that needs authorization token
154
 #### Download example : Fetch files that needs authorization token
146
 
155
 
483
 .then(...)
492
 .then(...)
484
 ```
493
 ```
485
 
494
 
495
+### File System
496
+
486
 #### File Access
497
 #### File Access
487
 
498
 
488
 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.
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
 })
642
 })
632
 ```
643
 ```
633
 
644
 
634
-#### Web API Polyfills
645
+### Web API Polyfills
635
 
646
 
636
 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. 
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