我正在用英特尔 xdk 为 android 和 ios 构建一个应用程序。我无法在 android 的 sdcard 上保存 pdf。我能够获取设备的文件目录,并且我的警报文本显示我进展顺利。但是当我尝试保存 pdf 时,什么也没有发生。该应用程序只是跳过“fileTransfer.download(...)”,没有例外,没有什么。
我可能遗漏了一些东西,但是不支持文件传输吗?一直在寻找,但没有运气。欢迎所有想法:o)
/安德斯我的代码:
function download()
{
window.appRootDirName = "download_test";
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
alert("device is ready");
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function fail() {
alert("failed to get filesystem");
}
function gotFS(fileSystem) {
alert("filesystem got");
window.fileSystem = fileSystem;
fileSystem.root.getDirectory(window.appRootDirName, {
create: true,
exclusive: false
}, dirReady, fail);
}
function dirReady(entry) {
window.appRootDir = entry;
alert("application dir is ready");
}
var filePathx = window.appRootDir.fullPath + "/test.pdf";
alert(filePathx);
try{
downloadFile = function() {
var fileTransfer = new FileTransfer();
var url = "http://myserver/file.pdf";
var filePath = window.appRootDir.fullPath + "/test.pdf";
fileTransfer.download(
url, filePath, function(entry) {
alert("download complete: " + entry.fullPath);
}, function(error) {
alert("download error" + error.source);
});
}
}
catch(e)
{
alert("error in filetransfer.download: " + e.message);
}
}