
升级后文件系统访问被破坏. (虽然似乎在模拟器中工作?)
我收到一条错误消息,指出“无法创建目标文件”,我Google了一下,并考虑将我的“完整路径”更改为“toURL()”,但无济于事.我真的不知道下一步该尝试什么?
这是我的下载代码
window.requestfileSystem(LocalfileSystem.PERSISTENT,function onfileSystemSuccess(fileSystem) {fileSystem.root.getfile( "dummy.HTML",{ create: true,exclusive: false},function gotfileEntry(fileEntry) { var sPath = fileEntry.toURL().replace("dummy.HTML",""); var fileTransfer = new fileTransfer(); fileEntry.remove(); fileTransfer.download( "https://dl.dropBox.com/u/13253550/db02.xml",sPath + "database.xml",function (thefile) { console.log("download complete: " + thefile.toURI()); showlink(thefile.toURI()); setTimeout(function () { checkConnection(); },50); },function (error) { console.log("download error source " + error.source); console.log("download error target " + error.target); console.log("upload error code: " + error.code); });},fail);},fail);解决方法 我找到了文件插件( link)和fileTransfer插件( link)的文档 在原始问题中进行了更改后,我想知道文件插件部分是否正常,并开始寻找我的fileTransfer代码和提供的示例之间的差异.
结果我没有在我的下载源url(doh)上做encodeURI()
所以完整的,有效的代码:
window.requestfileSystem(LocalfileSystem.PERSISTENT,function onfileSystemSuccess(fileSystem) {fileSystem.root.getfile("dummy.HTML",{create: true,function gotfileEntry(fileEntry) {var sPath = fileEntry.toURL().replace("dummy.HTML","");var fileTransfer = new fileTransfer();fileEntry.remove();var DBuri = encodeURI("https://dl.dropBox.com/u/13253550/db02.xml");fileTransfer.download( DBuri,function (thefile) { console.log("download complete: " + thefile.toURI()); showlink(thefile.toURI()); setTimeout(function () { checkConnection(); },50);},function (error) { console.log("download error source " + error.source); console.log("download error target " + error.target); console.log("upload error code: " + error.code);});},fail); 总结 以上是内存溢出为你收集整理的Cordova 3.4.0上的FileSystem失败“无法创建目标文件”全部内容,希望文章能够帮你解决Cordova 3.4.0上的FileSystem失败“无法创建目标文件”所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)