|
@@ -24,7 +24,7 @@ This module implements native methods, supports both Android (uses awesome nativ
|
24
|
24
|
* [Upload file](#user-content-upload-example--dropbox-files-upload-api)
|
25
|
25
|
* [Multipart/form upload](#user-content-multipartform-data-example--post-form-data-with-file-and-data)
|
26
|
26
|
* [Upload/Download progress](#user-content-uploaaddownload-progress)
|
27
|
|
- * [Show Downloaded File in Android Downloads App](#user-content-show-downloaded-file-in-android-downloads-app)
|
|
27
|
+ * [Show Downloaded File and Notification in Android Downloads App](#user-content-show-downloaded-file-in-android-downloads-app)
|
28
|
28
|
* [File access](#user-content-file-access)
|
29
|
29
|
* [File stream](#user-content-file-stream)
|
30
|
30
|
* [Manage cached files](#user-content-manage-cached-files)
|
|
@@ -296,7 +296,7 @@ In `version >= 0.4.2` it is possible to know the upload/download progress.
|
296
|
296
|
})
|
297
|
297
|
```
|
298
|
298
|
|
299
|
|
-#### Show Downloaded File in Android Downloads App
|
|
299
|
+#### Show Downloaded File and Notifiction in Android Downloads App
|
300
|
300
|
|
301
|
301
|
When you use `config` API to store response data to file, the file won't be visible in Andoird's "Download" app, if you want to do this, some extra options in `config` is required.
|
302
|
302
|
|
|
@@ -342,7 +342,7 @@ See [fs](#user-content-fs) chapter for more information
|
342
|
342
|
|
343
|
343
|
#### File Stream
|
344
|
344
|
|
345
|
|
-In `v0.5.0` we've added `writeStream` and `readStream`, which allows you 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**.
|
|
345
|
+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**.
|
346
|
346
|
|
347
|
347
|
But there're some differences between `readStream` and `writeStream` API. When calling `readStream` method, the file stream is opened immediately, and start to read data.
|
348
|
348
|
|
|
@@ -369,7 +369,7 @@ ifstream.onEnd(() => {
|
369
|
369
|
|
370
|
370
|
When use `writeStream`, the stream is also opened immediately, but you have to `write`, and `close` by yourself.
|
371
|
371
|
|
372
|
|
-```
|
|
372
|
+```js
|
373
|
373
|
let ofstream = RNFetchBlob.writeStream(
|
374
|
374
|
PATH_TO_FILE,
|
375
|
375
|
// encoding, should be one of `base64`, `utf8`, `ascii`
|
|
@@ -443,10 +443,14 @@ You can also group the requests by using `session` API, and use `dispose` to rem
|
443
|
443
|
|
444
|
444
|
#### `config(options:RNFetchBlobConfig):fetch`
|
445
|
445
|
|
|
446
|
+`0.5.0`
|
|
447
|
+
|
446
|
448
|
Config API was introduced in `v0.5.0` which provides some options for the `fetch` task.
|
447
|
449
|
|
448
|
450
|
#### `fetch(method, url, headers, body):Promise<FetchBlobResponse>`
|
449
|
451
|
|
|
452
|
+`legacy`
|
|
453
|
+
|
450
|
454
|
Send a HTTP request uses given headers and body, and return a Promise.
|
451
|
455
|
|
452
|
456
|
#### method:`string` Required
|
|
@@ -459,7 +463,9 @@ Headers of HTTP request, value of headers should be `stringified`, if you're upl
|
459
|
463
|
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.
|
460
|
464
|
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`.
|
461
|
465
|
|
462
|
|
-#### `fetch(...).progress(eventListener):Promise<FetchBlobResponse>` added in `0.4.2`
|
|
466
|
+#### `fetch(...).progress(eventListener):Promise<FetchBlobResponse>`
|
|
467
|
+
|
|
468
|
+`0.4.2`
|
463
|
469
|
|
464
|
470
|
Register on progress event handler for a fetch request.
|
465
|
471
|
|
|
@@ -473,6 +479,8 @@ TODO
|
473
|
479
|
|
474
|
480
|
#### `base64`
|
475
|
481
|
|
|
482
|
+`0.4.2`
|
|
483
|
+
|
476
|
484
|
A helper object simply uses [base-64](https://github.com/mathiasbynens/base64) for decode and encode BASE64 data.
|
477
|
485
|
|
478
|
486
|
```js
|
|
@@ -482,8 +490,30 @@ RNFetchBlob.base64.decode(data)
|
482
|
490
|
|
483
|
491
|
#### `fs`
|
484
|
492
|
|
|
493
|
+`0.5.0`
|
|
494
|
+
|
|
495
|
+#### `getSystemDirs()`
|
|
496
|
+
|
|
497
|
+This method returns common used folders:
|
|
498
|
+
|
|
499
|
+- DocumentDir
|
|
500
|
+- CacheDir
|
|
501
|
+- DCIMDir (Android Only)
|
|
502
|
+- DownloadDir (Android Only)
|
|
503
|
+
|
|
504
|
+example
|
|
505
|
+
|
|
506
|
+```js
|
|
507
|
+```
|
|
508
|
+
|
|
509
|
+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).
|
|
510
|
+
|
|
511
|
+#### createFile(path:string, data:string, encoding:string ):Promise
|
|
512
|
+
|
485
|
513
|
TODO
|
486
|
514
|
|
|
515
|
+
|
|
516
|
+
|
487
|
517
|
### Types
|
488
|
518
|
|
489
|
519
|
#### RNFetchBlobConfig
|