我在IOS 8.1上使用org.apache.cordova.file
插件最新版本,但是当我尝试创建文件时没有任何反应:
getRootDirectory();
function getRootDirectory() {
console.log("getting root dir");
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fail);
}
function gotFS(fileSystem) {
console.log('got fs', fileSystem);
var fileName = "capb_logs.txt";
var filePath = fileSystem.root.fullPath;
if (filePath === '/') {filePath = '';}
path = filePath + "/" + fileName;
fileSystem.root.getFile(fileName, { create: true, exclusive: false }, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
console.log('gotFileEntry',fileEntry );
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
console.log('gotFileWriter');
writer.onwriteend = function(evt) {
emailHandler.sendEmailWithAttachments({
subject: 'CA Executive Playbook - Debug Logs',
body: 'Log file attached',
attachments: [{
filePath: path
}],
});
};
var logs = log.getAllLogs(false);
writer.write(logs);
}
function fail(error) {
console.log('Failed to get file', error);
util.showMessage('Error', 'There was a problem in opening an email client');
de.reject(error);
}
我使用gotFs
方法,但是当我调用fileSystem.root.getFile(fileName, { create: true, exclusive: false }, gotFileEntry, fail);
没有任何反应时,调用成功或失败的回调都没有被调用。
这是我得到的文件系统对象: