Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit ec47aaf

Browse files
authored
Update README.md
1 parent b8125f0 commit ec47aaf

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A project committed to make file acess and data transfer easier, effiecient for
1313
* [About](#user-content-about)
1414
* [Installation](#user-content-installation)
1515
* [Recipes](#user-content-recipes)
16-
* HTTP Data Transfer
16+
* [HTTP Data Transfer](#user-content-http-data-transfer)
1717
* [Regular Request](#user-content-regular-request)
1818
* [Download file](#user-content-download-example--fetch-files-that-needs-authorization-token)
1919
* [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
2222
* [Cancel HTTP request](#user-content-cancel-request)
2323
* [Android Media Scanner, and Download Manager Support](#user-content-android-media-scanner-and-download-manager-support)
2424
* [Self-Signed SSL Server](#user-content-self-signed-ssl-server)
25-
* File System
25+
* [File System](#user-content-file-system)
2626
* [File access](#user-content-file-access)
2727
* [File stream](#user-content-file-stream)
2828
* [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`.
133133
var RNFetchBlob = require('react-native-fetch-blob').default
134134
```
135135

136-
#### Regular Request
136+
### HTTP Data Transfer
137+
138+
---
137139

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
139141

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
141143

142144
<img src="img/RNFB-flow (1).png" style="width : 90%" />
143145

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`.
144153

145154
#### Download example : Fetch files that needs authorization token
146155

@@ -483,6 +492,8 @@ RNFetchBlob.config({
483492
.then(...)
484493
```
485494

495+
### File System
496+
486497
#### File Access
487498

488499
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({
631642
})
632643
```
633644

634-
#### Web API Polyfills
645+
### Web API Polyfills
635646

636647
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.
637648

0 commit comments

Comments
 (0)