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

[WIP] Feature: parametrizable UI document interaction controller #570

Open
wants to merge 29 commits into
base: 0.11.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8121dbf
Apply possible fix to fs.readFile and fs.readStream for #287
wkh237 Mar 27, 2017
4d15c0f
Merge branch '0.10.5' into issue-287-wip
wkh237 Apr 16, 2017
40fefd4
Add Android fs.readFile app provider URI support #287
wkh237 Apr 16, 2017
50a4d06
Merge branch 'issue-287-merged' into uri
wkh237 Jul 2, 2017
a8cfeb1
Correct app content provider URI handle #287
wkh237 Jul 2, 2017
bb7fec4
Merge branch 'issue-287' of github.com:wkh237/react-native-fetch-blob…
wkh237 Jul 2, 2017
08f8403
Fixed a bug which causes XMLHttpRequest getting incorrect header when…
wkh237 Jul 3, 2017
c217fab
Merge branch 'uri' into 0.10.7
wkh237 Jul 3, 2017
8a75a9b
Set mime if set in addAndroidDownloads (#421)
jsm Jul 3, 2017
ed2732a
Fix Download Manager bug when the file is not a multimedia #391
wkh237 Jul 5, 2017
dd4dbb2
Merge branch '0.10.7' of github.com:wkh237/react-native-fetch-blob in…
wkh237 Jul 5, 2017
6bb7c65
Add support for TLS 1.2 when running Android 4 (#430)
jhellman Jul 14, 2017
b70a124
Update README.md
wkh237 Jul 14, 2017
712c8a3
[iOS] Fix for RNFetchBlob.writeChunk failing to write base64 encoded …
joshbax Jul 17, 2017
d83d800
Add missing API Blob.safeClose()
wkh237 Jul 25, 2017
d1d07d0
Fix Compilation Error in React Native 0.47.0 (#452)
Hizoul Aug 2, 2017
206588f
Merge branch 'master' of github.com:wkh237/react-native-fetch-blob in…
wkh237 Aug 2, 2017
6bde516
Bump to 0.10.7
wkh237 Aug 2, 2017
5f3c018
Merge branch '0.10.7' of github.com:wkh237/react-native-fetch-blob in…
wkh237 Aug 2, 2017
50c1573
Update PULL_REQUEST_TEMPLATE
wkh237 Aug 2, 2017
55009f1
Correct unterminated string #455
wkh237 Aug 3, 2017
9ab4ebb
bump to 0.10.8
bcpclone Aug 3, 2017
4c133d6
refs #51397 Added parameters to UIDocumentInteractionController
Oct 24, 2017
37d1e73
refs #51397 Added parameters to UIDocumentInteractionController
Oct 24, 2017
11d9b65
Added parameters to UIDocumentInteractionController
Oct 24, 2017
a93abc6
Support to change color of navigation bar
Moreno97 Oct 24, 2017
45c200f
Support to change background color of the navigation bar on iOS
Oct 31, 2017
ce06de4
Merge remote-tracking branch 'upstream/0.10.8' into _parametrizable_u…
Nov 17, 2017
8b0aa72
Solved merge issue
Nov 17, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Thank you for making a pull request ! Just a gentle reminder :)

1. If the PR is offering a feature please make the request to our "Feature Branch" 0.11.0
2. Bug fix request to "Bug Fix Branch" 0.10.7
2. Bug fix request to "Bug Fix Branch" 0.10.8
3. Correct README.md can directly to master
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ A project committed to making file access and data transfer easier and more effi
* [Android Media Scanner, and Download Manager Support](#user-content-android-media-scanner-and-download-manager-support)
* [Self-Signed SSL Server](#user-content-self-signed-ssl-server)
* [Transfer Encoding](#user-content-transfer-encoding)
* [RNFetchBlob as Fetch](#user-content-rnfetchblob-as-fetch)
* [Drop-in Fetch Replacement](#user-content-drop-in-fetch-replacement)
* [File System](#user-content-file-system)
* [File access](#user-content-file-access)
* [File stream](#user-content-file-stream)
* [Manage cached files](#user-content-cache-file-management)
* [Web API Polyfills](#user-content-web-api-polyfills)
* [Performance Tips](#user-content-performance-tipsd)
* [Performance Tips](#user-content-performance-tips)
* [API References](https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API)
* [Caveats](#user-content-caveats)
* [Development](#user-content-development)
Expand Down Expand Up @@ -494,11 +494,11 @@ task.cancel((err) => { ... })

```

### RNFetchBlob as Fetch
### Drop-in Fetch Replacement

0.9.0

If you have existing code that uses `whatwg-fetch`(the official **fetch**), you don't have to change them after 0.9.0, just use fetch replacement. The difference between Official fetch and fetch replacement is, official fetch uses [whatwg-fetch](https://github.com/github/fetch) js library which wraps XMLHttpRequest polyfill under the hood it's a great library for web developers, however that does not play very well with RN. Our implementation is simply a wrapper of RNFetchBlob.fetch and fs APIs, so you can access all the features we provide.
If you have existing code that uses `whatwg-fetch`(the official **fetch**), it's not necessary to replace them with `RNFetchblob.fetch`, you can simply use our **Fetch Replacement**. The difference between Official them is official fetch uses [whatwg-fetch](https://github.com/github/fetch) which wraps XMLHttpRequest polyfill under the hood. It's a great library for web developers, but does not play very well with RN. Our implementation is simply a wrapper of our `fetch` and `fs` APIs, so you can access all the features we provided.

[See document and examples](https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API#fetch-replacement)

Expand Down Expand Up @@ -655,6 +655,8 @@ In `v0.5.0` we've added `writeStream` and `readStream`, which allows your app r

When calling `readStream` method, you have to `open` the stream, and start to read data. When the file is large, consider using an appropriate `bufferSize` and `interval` to reduce the native event dispatching overhead (see [Performance Tips](#user-content-performance-tips))

> The file stream event has a default throttle(10ms) and buffer size which preventing it cause too much overhead to main thread, yo can also [tweak these values](#user-content-performance-tips).

```js
let data = ''
RNFetchBlob.fs.readStream(
Expand Down
29 changes: 23 additions & 6 deletions android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,28 @@ static public void writeFile(String path, ReadableArray data, final boolean appe
* @param promise
*/
static public void readFile(String path, String encoding, final Promise promise ) {
path = normalizePath(path);
String resolved = normalizePath(path);
if(resolved != null)
path = resolved;
try {
byte[] bytes;

if(path.startsWith(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET)) {
if(resolved != null && resolved.startsWith(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET)) {
String assetName = path.replace(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET, "");
long length = RNFetchBlob.RCTContext.getAssets().openFd(assetName).getLength();
bytes = new byte[(int) length];
InputStream in = RNFetchBlob.RCTContext.getAssets().open(assetName);
in.read(bytes, 0, (int) length);
in.close();
}
// issue 287
else if(resolved == null) {
InputStream in = RNFetchBlob.RCTContext.getContentResolver().openInputStream(Uri.parse(path));
int length = (int) in.available();
bytes = new byte[length];
in.read(bytes);
in.close();
}
else {
File f = new File(path);
int length = (int) f.length();
Expand Down Expand Up @@ -238,17 +248,24 @@ static public String getTmpPath(ReactApplicationContext ctx, String taskId) {
* @param bufferSize Buffer size of read stream, default to 4096 (4095 when encode is `base64`)
*/
public void readStream(String path, String encoding, int bufferSize, int tick, final String streamId) {
path = normalizePath(path);
String resolved = normalizePath(path);
if(resolved != null)
path = resolved;
try {

int chunkSize = encoding.equalsIgnoreCase("base64") ? 4095 : 4096;
if(bufferSize > 0)
chunkSize = bufferSize;

InputStream fs;
if(path.startsWith(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET)) {
fs = RNFetchBlob.RCTContext.getAssets()
.open(path.replace(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET, ""));

if(resolved != null && path.startsWith(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET)) {
fs = RNFetchBlob.RCTContext.getAssets().open(path.replace(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET, ""));

}
// fix issue 287
else if(resolved == null) {
fs = RNFetchBlob.RCTContext.getContentResolver().openInputStream(Uri.parse(path));
}
else {
fs = new FileInputStream(new File(path));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public List<NativeModule> createNativeModules(ReactApplicationContext reactConte
return modules;
}

@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
Expand Down
Loading