React-native-fetch-blob: the problem "...exposed beyond app through Intent.getData() " at Android N

Created on 14 May 2017  路  8Comments  路  Source: wkh237/react-native-fetch-blob

help

android discussion question

Most helpful comment

This could be a result of how RNFB uses PathResolver.getRealPathFromURI and the new File API to read files from common filesystem document providers instead of using getContentResolver().openInputStream(uri).

All 8 comments

@xiaozhicheng , please provide more detailed information about this issue, thanks.

The problem occurred on the Android 7 model,
installing Apk times wrong: android.os.FileUriExposedException:, file://xxxxx.apk, exposed, beyond, app, through, Intent.getData ()

This could be a result of how RNFB uses PathResolver.getRealPathFromURI and the new File API to read files from common filesystem document providers instead of using getContentResolver().openInputStream(uri).

@wkh237 In this context, is it possible this function is wrong?

https://github.com/wkh237/react-native-fetch-blob/blob/master/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java#L62

It is

public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data)

but if I see this right it should be

public void onActivityResult(int requestCode, int resultCode, Intent data)

Reference: https://developer.android.com/training/basics/intents/result.html

That change also satisfies Android studio, which complains about that method. It also complains about the empty onNewIntent just below ("Method does not override method from its superclass").

I don't want to change anything in the "fetch" part of the code, I only do filesystem (fs.methods)...

I am just doing android.actionViewIntent(res.path(), 'image/png')( where res.path() returns '/storage/emulated/0/Download/CatHat1.jpg' ) and it is giving me this error . Full stack trace of error :

Possible Unhandled Promise Rejection (id: 0):
Error: file:///storage/emulated/0/Download/CatHat1.jpg exposed beyond app through Intent.getData()
Error: file:///storage/emulated/0/Download/CatHat1.jpg exposed beyond app through Intent.getData()
    at createErrorFromErrorData (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:1787:15)
    at http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:1744:25
    at MessageQueue.__invokeCallback (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2097:16)
    at http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:1890:15
    at MessageQueue.__guard (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2028:9)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:1889:13)
    at http://localhost:8081/debuggerWorker.js:72:58

Is any workaround or any kind of solution to this problem possible? If yes then please tell me as and when possible. I just want to open the downloaded file in its default file opener.

Update , This is not working on android N(7.0) only. It worked fine in 6.0. So i think whatever @sagar-teallabs and @dantman have written is the ultimate problem . Does anyone have a workaround or solution to this?

Was this page helpful?
0 / 5 - 0 ratings