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

Commit 2ad9ab2

Browse files
committed
Merge remote-tracking branch 'wkh237/master' into feat_45
* wkh237/master: Update README.md Update README.md Update README.md Updates readStream example to use `fs` package Update README.md
2 parents 17f2ab9 + eb76e53 commit 2ad9ab2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
# react-native-fetch-blob [![npm](https://img.shields.io/npm/v/react-native-fetch-blob.svg?style=flat-square)](https://www.npmjs.com/package/react-native-fetch-blob) ![](https://img.shields.io/badge/PR-Welcome-brightgreen.svg?style=flat-square) [![npm](https://img.shields.io/npm/l/express.svg?maxAge=2592000&style=flat-square)]() [![npm](https://img.shields.io/badge/inProgress-0.7.0-yellow.svg?style=flat-square)]()
1+
# react-native-fetch-blob [![npm](https://img.shields.io/npm/v/react-native-fetch-blob.svg?style=flat-square)](https://www.npmjs.com/package/react-native-fetch-blob) ![](https://img.shields.io/badge/PR-Welcome-brightgreen.svg?style=flat-square) [![npm](https://img.shields.io/npm/l/express.svg?maxAge=2592000&style=flat-square)]() [![npm](https://img.shields.io/badge/inProgress-0.7.0-yellow.svg?style=flat-square)](https://github.com/wkh237/react-native-fetch-blob/milestones)
22

33
A module provides upload, download, and files access API. Supports file stream read/write for process large files.
44

55
**Why do we need this**
66

7-
React Native does not support `Blob` object at this moment, which means if you're going to send/receive binary data via `fetch` API, that might not work as you expect. See [[fetch] Does fetch with blob() marshal data across the bridge?](https://github.com/facebook/react-native/issues/854).
7+
React Native does not support `Blob` object at this moment, which means if you're going to send/receive binary data via `fetch` API, that might not work as you expect. See [facebook/react-native#854](https://github.com/facebook/react-native/issues/854).
88

99
For some use cases, you might get into trouble. For example, displaying an image that requires a specific field in headers (ex. "Authorization : Bearer ...") or body, so you can't just pass the image uri to `Image` component because that will probably returns a 401 response. Or you're going to upload binary data which generated from JS, the server will get an empry body due to [this issue](https://github.com/facebook/react-native/issues/854). With help of APIs provided by this module, you can send HTTP request with any headers, and decide how to handle the response/reqeust data without worry about if it is not supported by `fetch` API. The response data can be just simply converted into BASE64 string, or stored to a file directly so that you can read it by using file access APIs such as readFile, readStream.
1010

1111
This module was designed to be a substitution of `Blob`, there's a set of APIs including basic file system CRUD method, and file stream reader/writer. Also it has a special `fetch` implementation that supports binary request/response body.
1212

13-
**Pre v0.5.0 Users**
13+
**Backward Compatible**
1414

15-
All updates are `backward-compatible` generally you don't have to change existing code unless you're going to use new APIs. In latest version (v0.5.0), new APIs can either `upload` or `download` files simply using a file path. It's much more memory efficent in some use case. We've also introduced `fs` APIs for access files, and `file stream` API that helps you read/write files (especially for **large ones**), see [Examples](#user-content-usage) bellow. This module implements native methods, supports both Android (uses awesome native library [AsyncHttpClient](https://github.com/AsyncHttpClient/async-http-client])) and IOS.
15+
All updates are `backward-compatible` generally you don't have to change existing code unless you're going to use new APIs. But we recommend pre `0.5.0` users consider upgrade the package to latest version, since we have introduced new APIs can either `upload` or `download` files simply using a file path. It's much more memory efficent in some use case. We've also introduced `fs` APIs for access files, and `file stream` API that helps you read/write files (especially for **large ones**), see [Examples](#user-content-usage) bellow. This module implements native methods, supports both Android (uses awesome native library [AsyncHttpClient](https://github.com/AsyncHttpClient/async-http-client])) and IOS.
1616

1717
## TOC
1818

1919
* [Installation](#user-content-installation)
20-
* [Guide](#user-content-guide)
20+
* [Recipes](#user-content-guide)
2121
* [Download file](#user-content-download-example--fetch-files-that-needs-authorization-token)
2222
* [Upload file](#user-content-upload-example--dropbox-files-upload-api)
2323
* [Multipart/form upload](#user-content-multipartform-data-example--post-form-data-with-file-and-data)
@@ -79,7 +79,7 @@ Also, if you're going to use `Android Download Manager` you have to add this to
7979

8080
Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app. So adding permissions in `AndroidManifest.xml` won't work in Android 6.0 devices. To grant permissions in runtime, you might use modules like [react-native-android-permissions](https://github.com/lucasferreira/react-native-android-permissions).
8181

82-
## Guide
82+
## Recipes
8383

8484
```js
8585
import RNFetchBlob from 'react-native-fetch-blob'
@@ -423,7 +423,7 @@ When calling `readStream` method, you have to `open` the stream, and start to re
423423

424424
```js
425425
let data = ''
426-
RNFetchBlob.readStream(
426+
RNFetchBlob.fs.readStream(
427427
// encoding, should be one of `base64`, `utf8`, `ascii`
428428
'base64',
429429
// file path
@@ -450,7 +450,7 @@ RNFetchBlob.readStream(
450450
When use `writeStream`, the stream is also opened immediately, but you have to `write`, and `close` by yourself.
451451

452452
```js
453-
RNFetchBlob.writeStream(
453+
RNFetchBlob.fs.writeStream(
454454
PATH_TO_FILE,
455455
// encoding, should be one of `base64`, `utf8`, `ascii`
456456
'utf8',

0 commit comments

Comments
 (0)