Browse Source

Update README.md

Ben Hsieh 8 years ago
parent
commit
734ee88dd5
1 changed files with 23 additions and 7 deletions
  1. 23
    7
      README.md

+ 23
- 7
README.md View File

@@ -69,10 +69,6 @@ RNFetchBlob.fetch('GET', 'http://www.example.com/images/img1.png', {
69 69
 
70 70
 #### Download to storage directly
71 71
 
72
-If you want to save the response data directly into file storage rather than convert response data into base64 for some reason.
73
-
74
-Put a `config` before calling `fetch`. There're three options which are `path`, `fileCache`, and `appendExt` that let you decide how and where to save the file.
75
-
76 72
 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.
77 73
 
78 74
 ```js
@@ -91,6 +87,8 @@ RNFetchBlob
91 87
   })
92 88
 ```
93 89
 
90
+**Set Temp File Extension**
91
+
94 92
 But in some cases, you might need a file extension even the file is temporary cached. For instance, when use the file path as source of `Image` element the path should end with something like .png or .jpg, you can do this by put one more option in to `config`.
95 93
 
96 94
 ```js
@@ -111,6 +109,7 @@ RNFetchBlob
111 109
     imageView = <Image source={{ uri : Platform.OS === 'android' ? 'file://' : '' + res.path() }}/>
112 110
   })
113 111
 ```
112
+**Use Specific File Path**
114 113
 
115 114
 What's more, if you prefer a specific path, rather a random generated path, you can use `path` option. We've added a [getSystemDirs](#user-content-getsysdirs) API in v0.5.0 that lists several common used directories.
116 115
 
@@ -266,9 +265,9 @@ let stream = RNFetchBlob.readStream(
266 265
     'base64',
267 266
     // file path
268 267
     PATH_TO_THE_FILE,
269
-    // (optional) buffer size, default to 1024 (1026 for BASE64 encoded data)
268
+    // (optional) buffer size, default to 4096 (4098 for BASE64 encoded data)
270 269
     // when reading file in BASE64 encoding, buffer size must be multiples of 3.
271
-    1026)
270
+    4098)
272 271
 stream.onData((chunk) => {
273 272
   data += chunk
274 273
 })
@@ -282,9 +281,18 @@ stream.onEnd(() => {
282 281
 
283 282
 #### Release cache files
284 283
 
284
+TODO
285 285
 
286 286
 ## API
287 287
 
288
+#### `getSystemDirs`
289
+
290
+TODO
291
+
292
+#### `config`
293
+
294
+TODO
295
+
288 296
 #### `fetch(method, url, headers, body):Promise<FetchBlobResponse>`
289 297
 
290 298
 Send a HTTP request uses given headers and body, and return a Promise.
@@ -316,7 +324,15 @@ RNFetchBlob.base64.encode(data)
316 324
 RNFetchBlob.base64.decode(data)
317 325
 ```
318 326
 
319
-### FetchBlobResponse
327
+#### `unlink`
328
+
329
+TODO
330
+
331
+#### `readStream`
332
+
333
+TODO
334
+
335
+#### FetchBlobResponse
320 336
 
321 337
 When `fetch` success, it resolve a `FetchBlobResponse` object as first argument. `FetchBlobResponse` object has the following methods (these method are synchronous, so you might take quite a performance impact if the file is big)
322 338