我正在尝试使用 cordova-file-plugin 和 ionic-native 获取文件的 base64 表示。但我得到一个安全错误。
使用 cordova-filechooser 选择文件。
this.fileChooser.open().then((uri) => {
const splitUri: Array<string> = uri.split('/');
const file: string = splitUri[splitUri.length - 1];
let path: string = uri.substring(0, uri.lastIndexOf("/"));
path = path + '/';
this.file.checkFile(path, file).then((exists: boolean) => {
console.log('checkFile', exists);
}, (error) => {
console.log('checkFile error', error);
});
this.file.readAsDataURL(path, file).then((result) => {
console.log('success', result);
}, (error) => {
console.log('read as data uri error', error);
});
如果我调用 readAsDataURL 方法,这就是我得到的
FileError {代码:2,消息:“SECURITY_ERR”}
我错过了什么吗?