Browse Source

Update README.md

wkh237 8 years ago
parent
commit
d7f0af3d40
1 changed files with 2 additions and 22 deletions
  1. 2
    22
      README.md

+ 2
- 22
README.md View File

148
 
148
 
149
 After `0.8.0` react-native-fetch-blob automatically decide how to send the body by checking `Content-Type` in header. 
149
 After `0.8.0` react-native-fetch-blob automatically decide how to send the body by checking `Content-Type` in header. 
150
 
150
 
151
-The rules are shown in the following sample
151
+The rules are shown in the following diagram
152
 
152
 
153
-```js
154
-import RNFetchblob from 'react-native-fetch-blob'
155
-
156
-// If body is an Array send as multipart form data
157
-RNFetchBlob.fetch('POST'),'http://upload.server.my' { /* whatever it is */  }, [{ name : 'field1', data : 'test' }])
158
-
159
-// If body is a string starts with prefix 'RNFetchBlob-file://' send request with input stream from the patg
160
-RNFetchBlob.fetch('POST'),'http://upload.server.my' { /* whatever it is */  }, 'RNFetchBlob-file://' + path)
161
-RNFetchBlob.fetch('POST'),'http://upload.server.my' { /* whatever it is */  }, RNFetchBlob.wrap(path))
162
-
163
-// If content-type contains `base64;` or `application/octet` the body will be decoded using BASE64 decoder 
164
-RNFetchBlob.fetch('POST','http://upload.server.my', { 'Content-Type' : 'anything;base64' }, BASE64_BODY)
165
-RNFetchBlob.fetch('POST','http://upload.server.my', { 'Content-Type' : 'application/octet-binary' }, BASE64_BODY)
166
-
167
-// Send the data as the string you given
168
-RNFetchBlob.fetch('POST', 'http://upload.server.my', { /*any content-type not matching above rules*/ 'Content-Type' : 'text/foo' }, data)
169
-RNFetchBlob.fetch('POST', 'http://upload.server.my', { 'text/plain' }, 'text in the body')
170
-RNFetchBlob.fetch('POST', 'http://upload.server.my', { 'application/json' }, JSON.stringify(some_data))
171
-
172
-```
153
+<img src="img/RNFB-flow.png" style="width : 90% />
173
 
154
 
174
-If no 'Content-Type' field in headers, it will use default content type `application/octet-stream` and convert given `body` to binary data using BASE64 decoder.
175
 
155
 
176
 #### Download example : Fetch files that needs authorization token
156
 #### Download example : Fetch files that needs authorization token
177
 
157