1

我正在从远程服务器下载一个 vcs 文件,以便在 android phonegap 中的日历上添加事件..vcs 文件下载正确..我的问题是它提示我打开文件..所以用户无法自动加载事件.. any1 可以建议我一个插件或任何其他等效代码..

PS:我是android的新手:)

enter code here

<script>
document.addEventListener("deviceready", onDeviceReady, false);
     function onSuccess(fileSystem) {
    console.log(fileSystem.name);
    console.log(fileSystem.root.name);
}
function onDeviceReady(){
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, null);   
}

function win(file) {
var reader = new FileReader();
reader.onloadend = function(evt) {
    console.log("read success");
    console.log(evt.target.result);
};
reader.readAsText(file);
};

 var fail = function(evt) {
console.log(error.code); 
};
 function syncCal(){

var fileTransfer = new FileTransfer();
var uri = encodeURI(server address);
var filePath =  'file:///sdcard/london3.vcs';
fileTransfer.download(
uri,
    filePath,
    function(entry) {
        console.log("download complete: " + entry.fullPath);
        entry.file(win, fail);
        entry.file.open;
    },
    function(error) {
        console.log("download error source " + error.source);
        console.log("download error target " + error.target);
        console.log("upload error code" + error.code);
    },
    false,
    {
        headers: {
            "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
        }
    }
)

}

4

0 回答 0