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

Commit 285d3ee

Browse files
committed
Update README.md
1 parent e39d252 commit 285d3ee

File tree

1 file changed

+28
-46
lines changed

1 file changed

+28
-46
lines changed

README.md

Lines changed: 28 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ RNFetchBlob.fetch('GET', 'http://www.example.com/images/img1.png', {
9696

9797
#### Download to storage directly
9898

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.
100100

101101
**These files won't be removed automatically, please refer to [Cache File Management](#user-content-cache-file-management)**
102102

@@ -177,8 +177,8 @@ RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
177177
mute : false
178178
}),
179179
'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).
182182
// The data will be converted to "byte array"(say, blob) before request sent.
183183
}, base64ImageString)
184184
.then((res) => {
@@ -253,7 +253,7 @@ What if you want to upload a file in some field ? Just like [upload a file from
253253
'Content-Type' : 'multipart/form-data',
254254
}, [
255255
// append field data from file path
256-
{
256+
{
257257
name : 'avatar',
258258
filename : 'avatar.png',
259259
// 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({
318318

319319
#### File Access
320320

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.
322322

323323
Here's the list of `fs` APIs
324324

@@ -340,7 +340,7 @@ See [fs](#user-content-fs) chapter for more information
340340

341341
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**.
342342

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.
344344

345345
```js
346346
let data = ''
@@ -372,7 +372,7 @@ When use `writeStream`, the stream is also opened immediately, but you have to `
372372

373373
```js
374374
let ofstream = RNFetchBlob.writeStream(
375-
PATH_TO_FILE,
375+
PATH_TO_FILE,
376376
// encoding, should be one of `base64`, `utf8`, `ascii`
377377
'utf8',
378378
// 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
444444

445445
#### `config(options:RNFetchBlobConfig):fetch`
446446

447+
---
448+
447449
`0.5.0`
448450

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.
450452

451453
see [RNFetchBlobConfig](#user-content-rnfetchblobconfig)
452454

453455
#### `fetch(method, url, headers, body):Promise<FetchBlobResponse>`
454456

457+
---
458+
455459
`legacy`
456460

457461
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
468472

469473
#### `fetch(...).progress(eventListener):Promise<FetchBlobResponse>`
470474

475+
---
476+
471477
`0.4.2`
472478

473479
Register on progress event handler for a fetch request.
@@ -482,6 +488,8 @@ TODO
482488

483489
#### `base64`
484490

491+
---
492+
485493
`0.4.2`
486494

487495
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)
493501

494502
#### `fs`
495503

504+
---
505+
496506
`0.5.0`
497507

498508
#### getSystemDirs():Promise<object>
499509

500510
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)
507515

508516
```js
509517
RNFetchBlob.getSystemDirs().then((dirs) => {
@@ -513,8 +521,7 @@ RNFetchBlob.getSystemDirs().then((dirs) => {
513521
console.log(dirs.DownloadDir)
514522
})
515523
```
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).
518525

519526
#### createFile(path, data, encoding):Promise
520527

@@ -544,7 +551,7 @@ Encoding of input data.
544551
#### append:`boolean`(optional, default to `false`)
545552
Will new data append after existing file or not.
546553

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.
548555

549556
```js
550557
// write utf8 data
@@ -568,7 +575,7 @@ RNFetchBlob.fs.writeStream(PATH_TO_WRITE, 'base64')
568575
stream.write(RNFetchBlob.base64.encode('foo'))
569576
return stream.close()
570577
})
571-
578+
572579
```
573580

574581
#### readStream(path, encoding, bufferSize):Promise<ReadStream>
@@ -583,7 +590,6 @@ Buffer size of read stream, default to `4096` and `4095`(when encoding is `base6
583590
`readStream` returns a promise which will resolve `RNFetchBlobReadStream`.
584591

585592
```js
586-
// read using `utf8`
587593
RNFetchBlob.fs.readStream(PATH_TO_READ, 'utf8')
588594
.then((stream) => {
589595
let data = ''
@@ -595,30 +601,6 @@ RNFetchBlob.fs.readStream(PATH_TO_READ, 'utf8')
595601
console.log(data)
596602
})
597603
})
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-
})
622604
```
623605

624606
#### mkdir(path:string):Promise
@@ -669,7 +651,7 @@ Check if a file exist at `path`
669651

670652
```js
671653
RNFetchBlob.fs.exists(PATH_OF_FILE)
672-
.then((exist) => {
654+
.then((exist) => {
673655
console.log(`file ${exist ? '' : 'not'} exists`)
674656
})
675657
.catch(() => { ... })
@@ -681,7 +663,7 @@ Check the file at `path` is a directory or not. Resolves with `false` when the p
681663

682664
```js
683665
RNFetchBlob.fs.exists(PATH_OF_FILE)
684-
.then((isDir) => {
666+
.then((isDir) => {
685667
console.log(`file is ${isDir ? '' : 'not'} a directory`)
686668
})
687669
```
@@ -715,7 +697,7 @@ A set of configurations that will be injected into a `fetch` method, with the fo
715697
- mime : MIME type of the file. By default is `text/plain`
716698
- 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))
717699
- notification : A `boolean` value decide whether show a notification when download complete.
718-
700+
719701

720702
#### RNFetchBlobResponse
721703

0 commit comments

Comments
 (0)