SEC_ERR尝试使用Ionic-native-file插件和angularfire将图像上传到Firebase时抛出

时间:2019-05-03 16:47:03

标签: typescript firebase ionic-framework

我正在尝试使用angularfire2软件包将Ionic应用程序中的图像上传到Firebase存储。似乎文件应该被发送到Firebase存储,但是它引发了错误SECURITY_ERR。我最初的想法是,它可能与权限相关,但是我对此不确定,将不胜感激! 在线搜索解决方案并向xml添加权限

 async uploadfn() {
   const files = await (<any>window).chooser.getFile("image/jpeg").then(async uri => {
      this.nativepath = uri.uri;
     console.log(this.nativepath);
    this.file.resolveLocalFilesystemUrl(this.nativepath).then(entry => {
     console.log(JSON.stringify(entry));
       let dirPath = entry.nativeURL;
        let dirPathSplit = dirPath.split("/");
           dirPathSplit.pop();
     dirPath = dirPathSplit.join("/");
     this.file.readAsArrayBuffer(dirPath, entry.name).then(async buffer=>{
        console.log(buffer);
       await this.upload(buffer, entry.name).catch(error => {
        console.log(error);
         });
    console.log("Success");
         })
     .catch(error => {
      console.log(error);
        });
       });
      });
     }

   async upload(buffer, name) {
 let blob = new Blob([buffer], { type: "image/jpeg" });
  console.log(blob);
   this.afStorage.upload(`tickets${name}`, blob).then(done => {
   console.log(done)}).catch(error => console.log(error));}

我应该在我的Firebase中有一个console.log('success')和一个文件    存储。但是我收到SECURITY_ERR

0 个答案:

没有答案