I am currently using the Corodova inappbrowser plugin to open files. It works fine on iOS, but not on Android. I found out that the Android browser does not support viewing files, so you need to use the system.
The problem I am facing is that I do not know how to get the file path.
Here is my code:
$scope.onResourceClick = function(url){
window.open(url, '_system', 'location=no');
};
url - relative path to the file, from index.html in the www folder.
So, I think my question is: how do I get the absolute path to the file.
I am moving forward. Using the Cordon File Plugin I can get several different paths. Still not sure what to use and where exactly the file is stored.
I use cordovaFile.checkFile to check if there is a file in the path that I'm trying to make, and I just guess to see if I can get luck and find it.
$cordovaFile.checkFile(cordova.file.dataDirectory, url)
.then(function (success) {
alert('yay' + success);
}, function (error) {
alert('nah' + error);
});
I tried
cordova.file.dataDirectorycordova.file.applicationDirectory
and add to the end of each of them the path from the www folder to my file and just the file name. I hope I'm lucky and find the right combination with the file, because I can not find the answer exploring.
Edit:
The workflow for what I'm trying to do has changed. I now store the files on the server and using api to return the url to the file. Then download the file to the device and open it.
Currently, I have everything except the download method used.
$cordovaFile.writeFile(cordova.file.externalDataDirectory, resourceFullName, resource.DocumentURL, true)
The download method downloads only 100 bytes of the file.
, - , writeFile , URL- , txt. , : .