瀏覽代碼

Update README.md

wkh237 8 年之前
父節點
當前提交
4d3d99f5f2
共有 1 個檔案被更改,包括 35 行新增23 行删除
  1. 35
    23
      README.md

+ 35
- 23
README.md 查看文件

442
 
442
 
443
 ## API
443
 ## API
444
 
444
 
445
-#### `config(options:RNFetchBlobConfig):fetch`
446
-
447
 ---
445
 ---
448
 
446
 
447
+### `config(options:RNFetchBlobConfig):fetch`
448
+
449
 `0.5.0`
449
 `0.5.0`
450
 
450
 
451
 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.
452
 
452
 
453
 see [RNFetchBlobConfig](#user-content-rnfetchblobconfig)
453
 see [RNFetchBlobConfig](#user-content-rnfetchblobconfig)
454
 
454
 
455
-#### `fetch(method, url, headers, body):Promise<FetchBlobResponse>`
456
-
457
 ---
455
 ---
458
 
456
 
457
+### `fetch(method, url, headers, body):Promise<FetchBlobResponse>`
458
+
459
 `legacy`
459
 `legacy`
460
 
460
 
461
 Send a HTTP request uses given headers and body, and return a Promise.
461
 Send a HTTP request uses given headers and body, and return a Promise.
470
 Body of the HTTP request, body can either be a BASE64 string, or an array contains object elements, each element have 2  required property `name`, and `data`, and 1 optional property `filename`, once `filename` is set, content in `data` property will be consider as BASE64 string that will be converted into byte array later.
470
 Body of the HTTP request, body can either be a BASE64 string, or an array contains object elements, each element have 2  required property `name`, and `data`, and 1 optional property `filename`, once `filename` is set, content in `data` property will be consider as BASE64 string that will be converted into byte array later.
471
 When body is a base64 string , this string will be converted into byte array in native code, and the request body will be sent as `application/octet-stream`.
471
 When body is a base64 string , this string will be converted into byte array in native code, and the request body will be sent as `application/octet-stream`.
472
 
472
 
473
-#### `fetch(...).progress(eventListener):Promise<FetchBlobResponse>`
474
-
475
 ---
473
 ---
476
 
474
 
475
+### `fetch(...).progress(eventListener):Promise<FetchBlobResponse>`
476
+
477
 `0.4.2`
477
 `0.4.2`
478
 
478
 
479
 Register on progress event handler for a fetch request.
479
 Register on progress event handler for a fetch request.
486
 
486
 
487
 TODO
487
 TODO
488
 
488
 
489
-#### `base64`
490
-
491
 ---
489
 ---
492
 
490
 
491
+### `base64`
492
+
493
+
493
 `0.4.2`
494
 `0.4.2`
494
 
495
 
495
 A helper object simply uses [base-64](https://github.com/mathiasbynens/base64) for decode and encode BASE64 data.
496
 A helper object simply uses [base-64](https://github.com/mathiasbynens/base64) for decode and encode BASE64 data.
499
 RNFetchBlob.base64.decode(data)
500
 RNFetchBlob.base64.decode(data)
500
 ```
501
 ```
501
 
502
 
502
-#### `fs`
503
-
504
 ---
503
 ---
505
 
504
 
505
+### `fs`
506
+
506
 `0.5.0`
507
 `0.5.0`
507
 
508
 
508
 #### getSystemDirs():Promise
509
 #### getSystemDirs():Promise
525
 
526
 
526
 #### createFile(path, data, encoding):Promise
527
 #### createFile(path, data, encoding):Promise
527
 
528
 
528
-#### path:`string`
529
+##### path:`string`
529
 The path which this new file will be created.
530
 The path which this new file will be created.
530
-#### data:`string` | `Array<number>`
531
+##### data:`string` | `Array<number>`
531
 Content of the new file, when `encoding` is `ascii`, this argument shoud be an array contains number 0~255.
532
 Content of the new file, when `encoding` is `ascii`, this argument shoud be an array contains number 0~255.
532
-#### encoding:`utf8` | `base64` | `ascii`
533
+##### encoding:`utf8` | `base64` | `ascii`
533
 Encoding of content.
534
 Encoding of content.
534
 
535
 
535
 the following expressions are equivalent.
536
 the following expressions are equivalent.
544
 
545
 
545
 #### writeStream(path:string, encoding:string, append:boolean):Promise<WriteStream>
546
 #### writeStream(path:string, encoding:string, append:boolean):Promise<WriteStream>
546
 
547
 
547
-#### path:`string`
548
+##### path:`string`
548
 The path to the file the stream is writing to.
549
 The path to the file the stream is writing to.
549
-#### encoding:`utf8` | `base64` | `ascii`
550
+##### encoding:`utf8` | `base64` | `ascii`
550
 Encoding of input data.
551
 Encoding of input data.
551
-#### append:`boolean`(optional, default to `false`)
552
+##### append:`boolean`(optional, default to `false`)
552
 Will new data append after existing file or not.
553
 Will new data append after existing file or not.
553
 
554
 
554
 Calling `writeStream` method will returns a Promise, which resolves a `RNFetchBlobWriteSteam` instance when stream opened successfully.
555
 Calling `writeStream` method will returns a Promise, which resolves a `RNFetchBlobWriteSteam` instance when stream opened successfully.
580
 
581
 
581
 #### readStream(path, encoding, bufferSize):Promise<ReadStream>
582
 #### readStream(path, encoding, bufferSize):Promise<ReadStream>
582
 
583
 
583
-#### path:`string`
584
+##### path:`string`
584
 The path to the file the stream is reading from.
585
 The path to the file the stream is reading from.
585
-#### encoding:`string`
586
+##### encoding:`string`
586
 Encoding of the data.
587
 Encoding of the data.
587
-#### bufferSize:`number`(optional)
588
+##### bufferSize:`number`(optional)
588
 Buffer size of read stream, default to `4096` and `4095`(when encoding is `base64`)
589
 Buffer size of read stream, default to `4096` and `4095`(when encoding is `base64`)
589
 
590
 
590
 `readStream` returns a promise which will resolve `RNFetchBlobReadStream`.
591
 `readStream` returns a promise which will resolve `RNFetchBlobReadStream`.
680
 
681
 
681
 ### Types
682
 ### Types
682
 
683
 
684
+---
685
+
683
 #### RNFetchBlobConfig
686
 #### RNFetchBlobConfig
684
 
687
 
688
+---
689
+
685
 A set of configurations that will be injected into a `fetch` method, with the following properties.
690
 A set of configurations that will be injected into a `fetch` method, with the following properties.
686
 
691
 
687
 #### fileCache:boolean
692
 #### fileCache:boolean
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))
703
   - 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))
699
   - notification : A `boolean` value decide whether show a notification when download complete.
704
   - notification : A `boolean` value decide whether show a notification when download complete.
700
 
705
 
706
+---
701
 
707
 
702
 #### RNFetchBlobResponse
708
 #### RNFetchBlobResponse
703
 
709
 
710
+---
711
+
704
 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)
712
 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)
705
 
713
 
706
 #### base64():string
714
 #### base64():string
719
 resp.session('session-name')
727
 resp.session('session-name')
720
 ```
728
 ```
721
 
729
 
730
+---
731
+
722
 #### RNFetchBlobSession
732
 #### RNFetchBlobSession
723
 
733
 
734
+---
735
+
724
 A `session` is an object that helps you manage files. It simply main a list of file path and let you use `dispose()`to delete files in this session once and for all.
736
 A `session` is an object that helps you manage files. It simply main a list of file path and let you use `dispose()`to delete files in this session once and for all.
725
 
737
 
726
 #### add(path:string):RNFetchBlobSession
738
 #### add(path:string):RNFetchBlobSession
736
 
748
 
737
 | Version | |
749
 | Version | |
738
 |---|---|
750
 |---|---|
739
-| ~0.3.0 | Upload/Download octet-stream and form-data |
740
-| 0.4.0 | Add base-64 encode/decode library and API |
741
-| 0.4.1 | Fixe upload form-data missing file extension problem on Android |
742
-| 0.4.2 | Supports upload/download progress |
743
 | 0.5.0 | Upload/download with direct access to file storage, and also added file access APIs |
751
 | 0.5.0 | Upload/download with direct access to file storage, and also added file access APIs |
752
+| 0.4.2 | Supports upload/download progress |
753
+| 0.4.1 | Fixe upload form-data missing file extension problem on Android |
754
+| 0.4.0 | Add base-64 encode/decode library and API |
755
+| ~0.3.0 | Upload/Download octet-stream and form-data |
744
 
756
 
745
 ### TODOs
757
 ### TODOs
746
 
758