window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem){
fileSystem.root.getFile(localPath, { create: false }, function(fileEntry) {
doSomethingGood();
}, function(err) {
alert(err.code);
});
});
localPath中指定的文件存在于我的Filesystem中。我仍然得到错误回调。它会警告代码:1000
。这很奇怪,因为根据dcoumentation,错误代码应该是FileError
中等于1到12(http://cordova.apache.org/docs/en/2.5.0/cordova_file_file.md.html#FileError)的错误代码之一。那么错误代码1000
想要告诉我什么?如果文件存在,为什么会抛出错误回调?
答案 0 :(得分:0)
代码1000似乎用于无效地址。
查看以下示例(从我的日志文件中提取,在Android设备上):
Read /storage/emulated/0/Android/data/com.my.app/cache/repositories/0001/summary.jpg not found
=> FileError code: 1
Read cache/repositories/0001/summary.jpg not found
=> FileError code: 1
Read file:///repositories/0001/summary.jpg not found
=> FileError code: 5
Read file:///cache/repositories/0001/summary.jpg not found
=> FileError code: 5
Read //cache/repositories/0001/summary.jpg not found
=> FileError code: 1000
Read /cache/repositories/0001/summary.jpg not found
=> FileError code: 1000
Read //repositories/0001/summary.jpg not found
=> FileError code: 1000
Read /repositories/0001/summary.jpg not found
=> FileError code: 1000
Read //storage/emulated/0/Android/data/com.my.app/cache/repositories/0001/summary.jpg not found
=> FileError code: 1000