3
使用Cordova FileOpener2和其他許多插件,如Cordova File,Cordova FileTransfer ..我無法在Android中找到我的本地PDF位置。Cordova FileOpener Android - 無法找到本地文件位置
此文件位於www/offline-files/
目錄中,當我在iOS中打開它(使用window.open(encodeURI('offline-files/myFile.pdf'), '_blank');
)時,它工作正常! 如果我在Android中嘗試相同的事情,它不起作用。例如,我多次嘗試中的一種:
function getPath()
{
// Get local path for Cordova
var path = window.location.pathname;
path = path.substr(path, path.length - 10);
return 'file://' + path;
}
cordova.plugins.fileOpener2.open(
getPath() + 'offline-files/myFile.pdf',
'application/pdf',
{
error: function (e)
{
console.log('Error status: ' + e.status + ' - Error message: ' + e.message);
},
success: function()
{
console.log('file opened successfully');
}
}
);
科爾多瓦返回我的日誌:"Error status: 9 - Error message: File not found"
還有一個奇怪的錯誤:科爾多瓦文件插件返回我沒有找到經典目錄的錯誤文件:
window.resolveLocalFileSystemURL(cordova.file.applicationDirectory,
function (dir)
{
/** SOME CODE **/
}
);