Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 4d3d99f

Browse files
committed
Update README.md
1 parent e5a5a20 commit 4d3d99f

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

README.md

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -442,20 +442,20 @@ You can also group the requests by using `session` API, and use `dispose` to rem
442442

443443
## API
444444

445-
#### `config(options:RNFetchBlobConfig):fetch`
446-
447445
---
448446

447+
### `config(options:RNFetchBlobConfig):fetch`
448+
449449
`0.5.0`
450450

451451
Config API was introduced in `v0.5.0` which provides some options for the `fetch` task.
452452

453453
see [RNFetchBlobConfig](#user-content-rnfetchblobconfig)
454454

455-
#### `fetch(method, url, headers, body):Promise<FetchBlobResponse>`
456-
457455
---
458456

457+
### `fetch(method, url, headers, body):Promise<FetchBlobResponse>`
458+
459459
`legacy`
460460

461461
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
470470
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.
471471
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`.
472472

473-
#### `fetch(...).progress(eventListener):Promise<FetchBlobResponse>`
474-
475473
---
476474

475+
### `fetch(...).progress(eventListener):Promise<FetchBlobResponse>`
476+
477477
`0.4.2`
478478

479479
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
486486

487487
TODO
488488

489-
#### `base64`
490-
491489
---
492490

491+
### `base64`
492+
493+
493494
`0.4.2`
494495

495496
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)
499500
RNFetchBlob.base64.decode(data)
500501
```
501502

502-
#### `fs`
503-
504503
---
505504

505+
### `fs`
506+
506507
`0.5.0`
507508

508509
#### getSystemDirs():Promise
@@ -525,11 +526,11 @@ RNFetchBlob.getSystemDirs().then((dirs) => {
525526
526527
#### createFile(path, data, encoding):Promise
527528

528-
#### path:`string`
529+
##### path:`string`
529530
The path which this new file will be created.
530-
#### data:`string` | `Array<number>`
531+
##### data:`string` | `Array<number>`
531532
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`
533534
Encoding of content.
534535

535536
the following expressions are equivalent.
@@ -544,11 +545,11 @@ fs.createFile(NEW_FILE_PATH, base64.encode('foo'), 'base64')
544545

545546
#### writeStream(path:string, encoding:string, append:boolean):Promise<WriteStream>
546547

547-
#### path:`string`
548+
##### path:`string`
548549
The path to the file the stream is writing to.
549-
#### encoding:`utf8` | `base64` | `ascii`
550+
##### encoding:`utf8` | `base64` | `ascii`
550551
Encoding of input data.
551-
#### append:`boolean`(optional, default to `false`)
552+
##### append:`boolean`(optional, default to `false`)
552553
Will new data append after existing file or not.
553554

554555
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')
580581

581582
#### readStream(path, encoding, bufferSize):Promise<ReadStream>
582583

583-
#### path:`string`
584+
##### path:`string`
584585
The path to the file the stream is reading from.
585-
#### encoding:`string`
586+
##### encoding:`string`
586587
Encoding of the data.
587-
#### bufferSize:`number`(optional)
588+
##### bufferSize:`number`(optional)
588589
Buffer size of read stream, default to `4096` and `4095`(when encoding is `base64`)
589590

590591
`readStream` returns a promise which will resolve `RNFetchBlobReadStream`.
@@ -680,8 +681,12 @@ RNFetchBlob.fs.unlink(path)
680681

681682
### Types
682683

684+
---
685+
683686
#### RNFetchBlobConfig
684687

688+
---
689+
685690
A set of configurations that will be injected into a `fetch` method, with the following properties.
686691

687692
#### fileCache:boolean
@@ -698,9 +703,12 @@ A set of configurations that will be injected into a `fetch` method, with the fo
698703
- 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))
699704
- notification : A `boolean` value decide whether show a notification when download complete.
700705

706+
---
701707

702708
#### RNFetchBlobResponse
703709

710+
---
711+
704712
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)
705713

706714
#### base64():string
@@ -719,8 +727,12 @@ RNFetchBlob.session('session-name').add(resp.path())
719727
resp.session('session-name')
720728
```
721729

730+
---
731+
722732
#### RNFetchBlobSession
723733

734+
---
735+
724736
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.
725737

726738
#### 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
736748

737749
| Version | |
738750
|---|---|
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 |
743751
| 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 |
744756

745757
### TODOs
746758

0 commit comments

Comments
 (0)