【发布时间】:2014-04-22 21:32:42
【问题描述】:
我正在尝试使用方法 setMetadata,使用 File 插件,但它似乎不起作用。
不执行任何成功或失败回调。当我使用 console.log(entry.setMetadata) 时,它会打印正确的方法。我使用 File 插件可以毫无问题地访问、创建和删除文件和文件夹。只有 setMetadata 不起作用。
例子:
localFileSystem = LocalFileSystem.PERSISTENT;
subFolder = "Backups";
metadataKey = "com.apple.MobileBackup";
metadataValue = 1;
window.requestFileSystem(localFileSystem, 0, function(fileSystem) {
fileSystem.root.getDirectory(subFolder, {create: true, exclusive: false}, function(parent) {
var data = {};
data[metadataKey] = metadataValue;
console.log(data); // OK
console.log(parent); // OK
parent.setMetadata(function() {
console.log("success setting metadata"); // Nothing
}, function() {
console.log("error setting metadata"); // Nothing
}, data);
}, function() {
console.log("error getting dir"); // Nothing, directory is OK
});
}, function(error) {
console.log(error.code); // No error here
});
【问题讨论】: