_openDocViewer(fileURL,filename){
console.log("OpeningDoc : "+fileURL);
OpenFile.openDoc([{
url: fileURL,
fileName : filename
}], (error, url) => {
if (error) {
console.log(error);
} else {
console.log(url)
}
});
}
_handleFilePress(fileURL){
const filename = fileURL.substring(fileURL.lastIndexOf('/')+1);
var filePath = RNFS.DocumentDirectoryPath+"/" ;
RNFS.exists(filePath+filename).then((fileExists) => {
console.log(fileExists);
if (fileExists) {
filePath = (Platform.OS === 'ios') ? filePath : "file://"+filePath;
this._openDocViewer(filePath+filename,filename);
} else {
console.log("Downloading File");
RNFS.downloadFile({fromUrl:fileURL, toFile: filePath+filename}).promise.then(res => {
filePath = (Platform.OS === 'ios') ? filePath : "file://"+filePath;
this._openDocViewer(filePath+filename,filename);
}).catch(err => {
console.log("downloadFileTest error: ", err)
});
}
});
}
java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/com.weconnect/files/July18_SMDiscussion.doc
at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:711)
at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:400)
at com.reactlibrary.RNReactNativeDocViewerModule$FileDownloaderAsyncTask.onPostExecute(RNReactNativeDocViewerModule.java:234)
at com.reactlibrary.RNReactNativeDocViewerModule$FileDownloaderAsyncTask.onPostExecute(RNReactNativeDocViewerModule.java:196)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)