![](/img/trans.png)
[英]Cordova/Phonegap FileTransfer.upload() error code = 1 (FILE_NOT_FOUND_ERR)
[英]Cordova FileEntry can't return File -> FILE_NOT_FOUND_ERR
我正在尝试从iOS文件系统获取文件。 我的文件位于:
console.log(PATH);
--> file:///var/mobile/Applications/B816F30B-791A-43E5-B33A-A26075E8B585/Documents/123123123.wav
现在,我想获得File
通过文件API
window.resolveLocalFileSystemURL(PATH, function(fileEntry){
console.log(fileEntry.fullPath); // /var/mobile/Applications/B816F30B-791A-43E5-B33A-A26075E8B585/Documents/123123123.wav
console.log(fileEntry.name); // 123123123.wav
console.log(fileEntry.toURL()); cdvfile://localhost/temporary/var/mobile/Applications/B816F30B-791A-43E5-B33A-A26075E8B585/Documents/123123123.wav
fileEntry.file(function(file){
// do stuff
}, function(error){
console.log(error);
});
});
找到了FileEntry
,但是当我调用file()
了一个FileError
,看起来像这样:
[Log] FileError (main.js, line 15569)
code: 1
__proto__: FileError
错误代码1为:NOT_FOUND_ERR。
为什么在找到FileEntry
且日志记录看起来正常时得到NOT_FOUND_ERR?
这是我的意思:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) {
console.log('file system open: ' + fs.name);
fs.root.getFile(fileName, {}, function (fileEntry) {
console.log("fileEntry is file?" + fileEntry.isFile.toString());
fileEntry.file(function (file) {
var reader = new FileReader();
reader.onloadend = function (evt) {
return success(evt.target.result);
};
reader.readAsDataURL(file);
});
}, function (e) {
throw JSON.stringify(e);
});
}, function (e) {
throw JSON.stringify(e);
});
您可以对其进行调整以使用您的URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.