2013-02-16 118 views
0

我发现我的设备的SD卡下载文件

application.downloadFile = function(file, callback) 
{ 
    window.requestFileSystem(
    LocalFileSystem.PERSISTENT, 0, 
    function onFileSystemSuccess(fileSystem) { 
     fileSystem.root.getFile(
     "dummy.html", {create: true, exclusive: false}, 
     function gotFileEntry(fileEntry) { 
     var sPath = fileEntry.fullPath.replace("dummy.html",""); 
     var fileTransfer = new FileTransfer(); 
     fileEntry.remove(); 

     fileTransfer.download(
      application.api+file, 
      sPath + "assas.json", 
      function(theFile) { 
       console.log("download complete: " + theFile.toURI()); 
       application.dataPath = theFile.toURI(); 
       callback(); 
      }, 
      function(error) { 
       console.log("download error source " + error.source); 
       console.log("download error target " + error.target); 
       console.log("upload error code: " + error.code); 
      } 
     ); 
     }); 
    }); 
}; 

代码工作正常,但它下载的代码在我的SD卡,我想下载我的文件dirrectly功能至极下载文件在我的应用程序。

在网络/数据单项

,但我不知道真的如何做到这一点

感谢

回答

1

不幸的是,WWW文件夹是只读的,你不能写它。您只能写入文件系统。

+0

好的,谢谢你的帮助 – Ajouve 2013-02-16 14:42:28