尝试使用cordova文件插件和ionic native获取文件的base64表示形式

尝试使用cordova文件插件和ionic native获取文件的base64表示形式,cordova,ionic-native,Cordova,Ionic Native,我正在尝试使用cordova文件插件和ionic native获取文件的base64表示。但我有一个安全错误 使用cordova文件选择器拾取该文件 this.fileChooser.open().then((uri) => { const splitUri: Array<string> = uri.split('/'); const file: string = splitUri[splitUri.length - 1]; let path: stri

我正在尝试使用cordova文件插件和ionic native获取文件的base64表示。但我有一个安全错误

使用cordova文件选择器拾取该文件

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);
    });
this.fileChooser.open()。然后((uri)=>{
常量splitUri:Array=uri.split('/');
常量文件:string=splitUri[splitUri.length-1];
let path:string=uri.substring(0,uri.lastIndexOf(“/”);
路径=路径+“/”;
this.file.checkFile(路径,文件).then((存在:布尔值)=>{
log('checkFile',存在);
},(错误)=>{
log('checkFile error',error);
});
this.file.readAsDataURL(路径,文件)。然后((结果)=>{
console.log('success',result);
},(错误)=>{
log('读取为数据uri错误',错误);
});
这就是我调用readAsDataURL方法得到的结果

FileError{代码:2,消息:“SECURITY_ERR”}

我遗漏了什么吗?

文件api不完整(例如getFreeDiskSpace、writeFile)和文档不完整(例如readAstext)

请参考此URL


您试图访问的路径是什么?可能是您没有读写权限的系统文件