error to filetransfer.download in android (erro code 1)

后端 未结 1 1118
我寻月下人不归
我寻月下人不归 2021-01-17 02:12
document.addEventListener(\'deviceready\', onDeviceReady, false);

function onDeviceReady() {
//request the persistent file system
    window.requestFileSystem(Local         


        
相关标签:
1条回答
  • 2021-01-17 02:57

    Try like this

    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function gotFS(fileSystem) {
               fileSystem.root.getDirectory("your dir", {create: true}, function fileSystemSuccess(fileSystem){
                    fileSystem.getFile("dummy.txt",{create: true,exclusive:false},function gotFileEntry(fileEntry){
                        var path = fileEntry.fullPath.replace("dummy.txt","");
                        fileEntry.remove();
                        var fileTransfer = new FileTransfer();
                        fileTransfer.download(FILE_DOWNLOAD_URL, path+""+your -savedName,function(theFile){
                            alert("File Downloaded Successfully " + theFile.toURI());
                        },function(error){
                            alert("File Transfer failed" + error.message);
                        });
                    },fail);
                });
        }, fail);
    
    0 讨论(0)
提交回复
热议问题