0
我试图用cordova-file-plugin和离子本机获得文件的base64表示。但是我得到了一个security_error。试图获得带有cordova文件插件和离子本机的文件的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”}
我缺少的东西?
什么是您试图访问的路径?它可能是一个系统文件,您没有读取或写入权限 – Akis