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

Commit 9b1edd2

Browse files
committed
Merge branch '0.9.7' into 0.10.0
2 parents c37ba9a + 74ae0ce commit 9b1edd2

File tree

653 files changed

+802
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

653 files changed

+802
-217
lines changed

.github/ISSUE_TEMPLATE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
Hi ! Thank you for reporting an issue, but we would like to remind you, we have a trouble shooting page in our wiki. You may want to take a look on that page :p
22

3+
* please provide the version of installed library and RN project.
4+
* a sample code snippet/repository is very helpful to spotting the problem.
35
* issues which have been tagged as 'needs feedback', will be closed after 2 weeks if receive no feedbacks.

.github/PULL_REQUEST_TEMPLATE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Thank you for making a pull request ! Just a gentle reminder :)
22

33
1. If the PR is offering a feature please make the request to our "Feature Branch" 0.10.0
4-
2. Bug fix request to "Bug Fix Branch" 0.9.4
4+
2. Bug fix request to "Bug Fix Branch" 0.9.6
55
3. Correct README.md can directly to master

README.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
A project committed to make file acess and data transfer easier, efficient for React Native developers.
66

7+
> The npm package is inside `src` folder, if you're going to install using github repository do not point to here directly
8+
79
## Features
810
- Transfer data directly from/to storage without BASE64 bridging
911
- File API supports normal files, Asset files, and CameraRoll files
1012
- Native-to-native file manipulation API, reduce JS bridging performance loss
1113
- File stream support for dealing with large file
1214
- Blob, File, XMLHttpRequest polyfills that make browser-based library available in RN (experimental)
1315

14-
> The npm package is inside `src` folder, if you're going to install via git repository do not directly poiint to this folder
15-
1616
## TOC
1717
* [About](#user-content-about)
1818
* [Installation](#user-content-installation)
@@ -157,6 +157,8 @@ To sum up :
157157
- Otherwise, if a string starts with `RNFetchBlob-file://` (which can simply done by `RNFetchBlob.wrap(PATH_TO_THE_FILE)`), it will try to find the data from the URI string after `RNFetchBlob-file://` and use it as request body.
158158
- To send the body as-is, simply use a `Content-Type` header not containing `;BASE64` or `application/octet`.
159159

160+
> It is Worth to mentioning that the HTTP request uses cache by default, if you're going to disable it simply add a Cache Control header `'Cache-Control' : 'no-store'`
161+
160162
> After 0.9.4, we disabled `Chunked` transfer encoding by default, if you're going to use it, you should explicitly set header `Transfer-Encoding` to `Chunked`.
161163
162164
### Download example : Fetch files that needs authorization token
@@ -268,7 +270,7 @@ RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
268270
}),
269271
'Content-Type' : 'application/octet-stream',
270272
// here's the body you're going to send, should be a BASE64 encoded string
271-
// (you can use "base64" APIs to make one).
273+
// (you can use "base64"(refer to the library 'mathiasbynens/base64') APIs to make one).
272274
// The data will be converted to "byte array"(say, blob) before request sent.
273275
}, base64ImageString)
274276
.then((res) => {
@@ -378,7 +380,7 @@ What if you want to append a file to form data ? Just like [upload a file from s
378380

379381
### Upload/Download progress
380382

381-
In `version >= 0.4.2` it is possible to know the upload/download progress. After `0.7.0` IOS and Android upload progress are also supported.
383+
In `version >= 0.4.2` it is possible to know the upload/download progress. After `0.7.0` IOS and Android upload progress are also supported.
382384

383385
```js
384386
RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
@@ -401,6 +403,30 @@ In `version >= 0.4.2` it is possible to know the upload/download progress. After
401403
})
402404
```
403405

406+
In `0.9.6`, you can specify an optional first argument which contains `count` and `interval` to limit progress event frequency (this will be done in native context in order to reduce RCT bridge overhead). Notice that `count` argument will not work if the server does not provide response content length.
407+
408+
409+
```js
410+
RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
411+
... some headers,
412+
'Content-Type' : 'octet-stream'
413+
}, base64DataString)
414+
// listen to upload progress event, emit every 250ms
415+
.uploadProgress({ interval : 250 },(written, total) => {
416+
console.log('uploaded', written / total)
417+
})
418+
// listen to download progress event, every 10%
419+
.progress({ count : 10 }, (received, total) => {
420+
console.log('progress', received / total)
421+
})
422+
.then((resp) => {
423+
// ...
424+
})
425+
.catch((err) => {
426+
// ...
427+
})
428+
```
429+
404430
### Cancel Request
405431

406432
After `0.7.0` it is possible to cancel a HTTP request. When the request cancel, it will definately throws an promise rejection, be sure to catch it.
@@ -709,10 +735,12 @@ Here's a [sample app](https://github.com/wkh237/rn-firebase-storage-upload-sampl
709735

710736
## Performance Tips
711737

712-
**Reduce RCT Bridge and BASE64 Overheard**
738+
**Read Stream Event Overhead**
713739

714740
When reading data via `fs.readStream` the process seems blocking JS thread when file is large, it's because the default buffer size is quite small (4kb) which result in large amount of events triggered in JS thread, try to increase the buffer size (for example 100kb = 102400) and set a larger interval (which is introduced in 0.9.4 default value is 10ms) to limit the frequency.
715741

742+
**Reduce RCT Bridge and BASE64 Overhead**
743+
716744
React Native connects JS and Native context by passing JSON around React Native bridge, and there will be an overhead to convert data before they sent to each side. When data is large, this will be quite a performance impact to your app, it's recommended to use file storage instead of BASE64 if possible.The following chart shows how much faster when loading data from storage than BASE64 encoded string on iphone 6.
717745

718746
<img src="img/performance_1.png" style="width : 100%"/>

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"name": "fetchblob-dev",
3-
"version": "0.9.5-beta.2",
2+
"name": "react-native-fetch-blob-dev-env",
3+
"description" : "RNFB development environment, not dist package",
4+
"version": "0.9.6",
45
"private": true,
56
"scripts": {
67
"start": "node node_modules/react-native/local-cli/cli.js start",

0 commit comments

Comments
 (0)