我需要创建一个文件并下载它的设备目录。我已经按照this教程使用cordova文件插件编写文件。我正在获得成功控制台但我无法在设备目录中找到该文件。但它完美无缺在android工作。没有在ios设备上工作。
这是我的代码
window.resolveLocalFileSystemURL(cordova.file.documentsDirectory, function(dir) {
console.log("got main dir",dir);
dir.getFile("log.txt", {create:true}, function(file) {
console.log("got the file", file);
logOb = file;
if(!logOb) return;
var log = "App started" + " [" + (new Date()) + "]\n";
console.log("going to log "+log);
logOb.createWriter(function(fileWriter) {
fileWriter.seek(fileWriter.length);
var blob = new Blob([log], {type:'text/plain'});
fileWriter.write(blob);
console.log("success");
}, false);
});
});
配置文件权限
<preference name="iosPersistentFileLocation" value="Documents" />
<preference name="iosPersistentFileLocation" value="Compatibility" />
<preference name="iosExtraFilesystems" value="library,library-nosync,documents,documents-nosync,cache,bundle,root" />
<preference name="iosPersistentFileLocation" value="Compatibility" />
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
<feature name="FileTransfer">
<param name="ios-package" value="CDVFileTransfer" />
</feature>
<feature name="File">
<param name="ios-package" value="CDVFile" />
</feature>
有人能帮忙吗?