Ver código fonte

Update README.md

wkh237 8 anos atrás
pai
commit
4d3d99f5f2
1 arquivos alterados com 35 adições e 23 exclusões
  1. 35
    23
      README.md

+ 35
- 23
README.md Ver arquivo

@@ -442,20 +442,20 @@ You can also group the requests by using `session` API, and use `dispose` to rem
442 442
 
443 443
 ## API
444 444
 
445
-#### `config(options:RNFetchBlobConfig):fetch`
446
-
447 445
 ---
448 446
 
447
+### `config(options:RNFetchBlobConfig):fetch`
448
+
449 449
 `0.5.0`
450 450
 
451 451
 Config API was introduced in `v0.5.0` which provides some options for the `fetch` task.
452 452
 
453 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 459
 `legacy`
460 460
 
461 461
 Send a HTTP request uses given headers and body, and return a Promise.
@@ -470,10 +470,10 @@ Headers of HTTP request, value of headers should be `stringified`, if you're upl
470 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 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 477
 `0.4.2`
478 478
 
479 479
 Register on progress event handler for a fetch request.
@@ -486,10 +486,11 @@ A function that triggers when there's data received/sent, first argument is the
486 486
 
487 487
 TODO
488 488
 
489
-#### `base64`
490
-
491 489
 ---
492 490
 
491
+### `base64`
492
+
493
+
493 494
 `0.4.2`
494 495
 
495 496
 A helper object simply uses [base-64](https://github.com/mathiasbynens/base64) for decode and encode BASE64 data.
@@ -499,10 +500,10 @@ RNFetchBlob.base64.encode(data)
499 500
 RNFetchBlob.base64.decode(data)
500 501
 ```
501 502
 
502
-#### `fs`
503
-
504 503
 ---
505 504
 
505
+### `fs`
506
+
506 507
 `0.5.0`
507 508
 
508 509
 #### getSystemDirs():Promise
@@ -525,11 +526,11 @@ RNFetchBlob.getSystemDirs().then((dirs) => {
525 526
 
526 527
 #### createFile(path, data, encoding):Promise
527 528
 
528
-#### path:`string`
529
+##### path:`string`
529 530
 The path which this new file will be created.
530
-#### data:`string` | `Array<number>`
531
+##### data:`string` | `Array<number>`
531 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 534
 Encoding of content.
534 535
 
535 536
 the following expressions are equivalent.
@@ -544,11 +545,11 @@ fs.createFile(NEW_FILE_PATH, base64.encode('foo'), 'base64')
544 545
 
545 546
 #### writeStream(path:string, encoding:string, append:boolean):Promise<WriteStream>
546 547
 
547
-#### path:`string`
548
+##### path:`string`
548 549
 The path to the file the stream is writing to.
549
-#### encoding:`utf8` | `base64` | `ascii`
550
+##### encoding:`utf8` | `base64` | `ascii`
550 551
 Encoding of input data.
551
-#### append:`boolean`(optional, default to `false`)
552
+##### append:`boolean`(optional, default to `false`)
552 553
 Will new data append after existing file or not.
553 554
 
554 555
 Calling `writeStream` method will returns a Promise, which resolves a `RNFetchBlobWriteSteam` instance when stream opened successfully.
@@ -580,11 +581,11 @@ RNFetchBlob.fs.writeStream(PATH_TO_WRITE, 'base64')
580 581
 
581 582
 #### readStream(path, encoding, bufferSize):Promise<ReadStream>
582 583
 
583
-#### path:`string`
584
+##### path:`string`
584 585
 The path to the file the stream is reading from.
585
-#### encoding:`string`
586
+##### encoding:`string`
586 587
 Encoding of the data.
587
-#### bufferSize:`number`(optional)
588
+##### bufferSize:`number`(optional)
588 589
 Buffer size of read stream, default to `4096` and `4095`(when encoding is `base64`)
589 590
 
590 591
 `readStream` returns a promise which will resolve `RNFetchBlobReadStream`.
@@ -680,8 +681,12 @@ RNFetchBlob.fs.unlink(path)
680 681
 
681 682
 ### Types
682 683
 
684
+---
685
+
683 686
 #### RNFetchBlobConfig
684 687
 
688
+---
689
+
685 690
 A set of configurations that will be injected into a `fetch` method, with the following properties.
686 691
 
687 692
 #### fileCache:boolean
@@ -698,9 +703,12 @@ A set of configurations that will be injected into a `fetch` method, with the fo
698 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 704
   - notification : A `boolean` value decide whether show a notification when download complete.
700 705
 
706
+---
701 707
 
702 708
 #### RNFetchBlobResponse
703 709
 
710
+---
711
+
704 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 714
 #### base64():string
@@ -719,8 +727,12 @@ RNFetchBlob.session('session-name').add(resp.path())
719 727
 resp.session('session-name')
720 728
 ```
721 729
 
730
+---
731
+
722 732
 #### RNFetchBlobSession
723 733
 
734
+---
735
+
724 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 738
 #### add(path:string):RNFetchBlobSession
@@ -736,11 +748,11 @@ A `session` is an object that helps you manage files. It simply main a list of f
736 748
 
737 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 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 757
 ### TODOs
746 758