소스 검색

Update README.md

Ben Hsieh 8 년 전
부모
커밋
285d3ee0dc
1개의 변경된 파일28개의 추가작업 그리고 46개의 파일을 삭제
  1. 28
    46
      README.md

+ 28
- 46
README.md 파일 보기

@@ -96,7 +96,7 @@ RNFetchBlob.fetch('GET', 'http://www.example.com/images/img1.png', {
96 96
 
97 97
 #### Download to storage directly
98 98
 
99
-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. 
99
+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.
100 100
 
101 101
 **These files won't be removed automatically, please refer to [Cache File Management](#user-content-cache-file-management)**
102 102
 
@@ -177,8 +177,8 @@ RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
177 177
       mute : false
178 178
     }),
179 179
     'Content-Type' : 'application/octet-stream',
180
-    // here's the body you're going to send, should be a BASE64 encoded string 
181
-    // (you can use "base64" APIs to make one). 
180
+    // here's the body you're going to send, should be a BASE64 encoded string
181
+    // (you can use "base64" APIs to make one).
182 182
     // The data will be converted to "byte array"(say, blob) before request sent.  
183 183
   }, base64ImageString)
184 184
   .then((res) => {
@@ -253,7 +253,7 @@ What if you want to upload a file in some field ? Just like [upload a file from
253 253
     'Content-Type' : 'multipart/form-data',
254 254
   }, [
255 255
     // append field data from file path
256
-    { 
256
+    {
257 257
       name : 'avatar',
258 258
       filename : 'avatar.png',
259 259
       // Change BASE64 encoded data to a file path with prefix `RNFetchBlob-file://` when the data comes from a file path
@@ -318,7 +318,7 @@ RNFetchBlob.config({
318 318
 
319 319
 #### File Access
320 320
 
321
-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 I realized that, it's hard to find a great solution to manage cached files, every one who use this moudle may need those APIs for there cases. 
321
+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 I realized that, it's hard to find a great solution to manage cached files, every one who use this moudle may need those APIs for there cases.
322 322
 
323 323
 Here's the list of `fs` APIs
324 324
 
@@ -340,7 +340,7 @@ See [fs](#user-content-fs) chapter for more information
340 340
 
341 341
 In `v0.5.0` we've added  `writeStream` and `readStream`, which allows your app read/write data from file path. This API creates a file stream, rather than convert whole data into BASE64 encoded string, it's handy when processing **large files**.
342 342
 
343
-When calling `readStream` method, you have to `open` the stream, and start to read data. 
343
+When calling `readStream` method, you have to `open` the stream, and start to read data.
344 344
 
345 345
 ```js
346 346
 let data = ''
@@ -372,7 +372,7 @@ When use `writeStream`, the stream is also opened immediately, but you have to `
372 372
 
373 373
 ```js
374 374
 let ofstream = RNFetchBlob.writeStream(
375
-    PATH_TO_FILE, 
375
+    PATH_TO_FILE,
376 376
     // encoding, should be one of `base64`, `utf8`, `ascii`
377 377
     'utf8',
378 378
     // should data append to existing content ?
@@ -444,14 +444,18 @@ You can also group the requests by using `session` API, and use `dispose` to rem
444 444
 
445 445
 #### `config(options:RNFetchBlobConfig):fetch`
446 446
 
447
+---
448
+
447 449
 `0.5.0`
448 450
 
449
-Config API was introduced in `v0.5.0` which provides some options for the `fetch` task. 
451
+Config API was introduced in `v0.5.0` which provides some options for the `fetch` task.
450 452
 
451 453
 see [RNFetchBlobConfig](#user-content-rnfetchblobconfig)
452 454
 
453 455
 #### `fetch(method, url, headers, body):Promise<FetchBlobResponse>`
454 456
 
457
+---
458
+
455 459
 `legacy`
456 460
 
457 461
 Send a HTTP request uses given headers and body, and return a Promise.
@@ -468,6 +472,8 @@ When body is a base64 string , this string will be converted into byte array in
468 472
 
469 473
 #### `fetch(...).progress(eventListener):Promise<FetchBlobResponse>`
470 474
 
475
+---
476
+
471 477
 `0.4.2`
472 478
 
473 479
 Register on progress event handler for a fetch request.
@@ -482,6 +488,8 @@ TODO
482 488
 
483 489
 #### `base64`
484 490
 
491
+---
492
+
485 493
 `0.4.2`
486 494
 
487 495
 A helper object simply uses [base-64](https://github.com/mathiasbynens/base64) for decode and encode BASE64 data.
@@ -493,17 +501,17 @@ RNFetchBlob.base64.decode(data)
493 501
 
494 502
 #### `fs`
495 503
 
504
+---
505
+
496 506
 `0.5.0`
497 507
 
498 508
 #### getSystemDirs():Promise<object>
499 509
 
500 510
 This method returns common used folders:
501
-* DocumentDir 
502
-* CacheDir
503
-* DCIMDir (Android Only)
504
-* DownloadDir (Android Only)
505
-
506
-example 
511
+- DocumentDir
512
+- CacheDir
513
+- DCIMDir (Android Only)
514
+- DownloadDir (Android Only)
507 515
 
508 516
 ```js
509 517
 RNFetchBlob.getSystemDirs().then((dirs) => {
@@ -513,8 +521,7 @@ RNFetchBlob.getSystemDirs().then((dirs) => {
513 521
     console.log(dirs.DownloadDir)
514 522
 })
515 523
 ```
516
-
517
-If you're going to make downloaded file visible in Android `Downloads` app, please see [Show Downloaded File and Notification in Android Downloads App](#user-content-show-downloaded-file-in-android-downloads-app).
524
+If you're going to make downloaded file visible in Android `Downloads` app, please see [Show Downloaded File and Notification in Android Downloads App](#user-content-show-downloaded-file-and-notifiction-in-android-downloads-app).
518 525
 
519 526
 #### createFile(path, data, encoding):Promise
520 527
 
@@ -544,7 +551,7 @@ Encoding of input data.
544 551
 #### append:`boolean`(optional, default to `false`)
545 552
 Will new data append after existing file or not.
546 553
 
547
-Calling `writeStream` method will returns a Promise, which resolves a `RNFetchBlobWriteSteam` instance when stream opened successfully. 
554
+Calling `writeStream` method will returns a Promise, which resolves a `RNFetchBlobWriteSteam` instance when stream opened successfully.
548 555
 
549 556
 ```js
550 557
 // write utf8 data
@@ -568,7 +575,7 @@ RNFetchBlob.fs.writeStream(PATH_TO_WRITE, 'base64')
568 575
         stream.write(RNFetchBlob.base64.encode('foo'))
569 576
         return stream.close()
570 577
     })
571
-    
578
+
572 579
 ```
573 580
 
574 581
 #### readStream(path, encoding, bufferSize):Promise<ReadStream>
@@ -583,7 +590,6 @@ Buffer size of read stream, default to `4096` and `4095`(when encoding is `base6
583 590
 `readStream` returns a promise which will resolve `RNFetchBlobReadStream`.
584 591
 
585 592
 ```js
586
-// read using `utf8` 
587 593
 RNFetchBlob.fs.readStream(PATH_TO_READ, 'utf8')
588 594
     .then((stream) => {
589 595
         let data = ''
@@ -595,30 +601,6 @@ RNFetchBlob.fs.readStream(PATH_TO_READ, 'utf8')
595 601
             console.log(data)
596 602
         })
597 603
     })
598
-// read using `ascii` 
599
-RNFetchBlob.fs.readStream(PATH_TO_READ, 'ascii')
600
-    .then((stream) => {
601
-        let data = []
602
-        stream.open()
603
-        stream.onData((chunk) => {
604
-            data = data.concat(data)
605
-        })
606
-        stream.onEnd(() => {
607
-            console.log(data)
608
-        })
609
-    })
610
-// read using `base64` 
611
-RNFetchBlob.fs.readStream(PATH_TO_READ, 'base64')
612
-    .then((stream) => {
613
-        let data = ''
614
-        stream.open()
615
-        stream.onData((chunk) => {
616
-            data += chunk
617
-        })
618
-        stream.onEnd(() => {
619
-            console.log(data)
620
-        })
621
-    })
622 604
 ```
623 605
 
624 606
 #### mkdir(path:string):Promise
@@ -669,7 +651,7 @@ Check if a file exist at `path`
669 651
 
670 652
 ```js
671 653
 RNFetchBlob.fs.exists(PATH_OF_FILE)
672
-.then((exist) => { 
654
+.then((exist) => {
673 655
     console.log(`file ${exist ? '' : 'not'} exists`)
674 656
 })
675 657
 .catch(() => { ... })
@@ -681,7 +663,7 @@ Check the file at `path` is a directory or not. Resolves with `false` when the p
681 663
 
682 664
 ```js
683 665
 RNFetchBlob.fs.exists(PATH_OF_FILE)
684
-.then((isDir) => { 
666
+.then((isDir) => {
685 667
     console.log(`file is ${isDir ? '' : 'not'} a directory`)
686 668
 })
687 669
 ```
@@ -715,7 +697,7 @@ A set of configurations that will be injected into a `fetch` method, with the fo
715 697
   - mime : MIME type of the file. By default is `text/plain`
716 698
   - mediaScannable : A `boolean` value, see [Officail Document](https://developer.android.com/reference/android/app/DownloadManager.html#addCompletedDownload(java.lang.String, java.lang.String, boolean, java.lang.String, java.lang.String, long, boolean))
717 699
   - notification : A `boolean` value decide whether show a notification when download complete.
718
-  
700
+
719 701
 
720 702
 #### RNFetchBlobResponse
721 703