Firebase身份验证错误代码:无法导航文件[重复]

问题描述 投票:0回答:1

这个问题在这里已有答案:

我正在使用离子框架来导航来自注册用户的图像文件,该用户使用uploadcare上传图像并将直接图像信息发送到firestore firebase数据库。我正在使用'ionic serve'命令打开我在Mozilla Firefox中打开的应用程序。当我上传图像时,我的inspect元素控制台出现了一些错误:

FirebaseError:[code = permission-denied]:权限丢失或不足

这是我的uploader.page.ts的代码


import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http'
import {AngularFirestore} from '@angular/fire/firestore';
import {UserService} from '../user.service';
import { firestore } from 'firebase/app';

@Component({
  selector: 'app-uploader',
  templateUrl: './uploader.page.html',
  styleUrls: ['./uploader.page.scss'],
})

export class UploaderPage implements OnInit {

  imageURL: string
  desc : string
  constructor(
      public http: Http,
      public afstore: AngularFirestore,
      public user: UserService) { }

  ngOnInit() {
  }

  createPost(){
    const image = this.imageURL
    const desc = this.desc

    this.afstore.doc('users/${this.user.getUID()}').update({
      posts: firestore.FieldValue.arrayUnion({
        image,
        desc
      })
    })

  }

  fileChanged(event){
    const files = event.target.files

    const data = new FormData()
    data.append('file', files[0])
    data.append('UPLOADCARE_STORE', '1')
    data.append('UPLOADCARE_PUB_KEY','46efb6e9d65277034002')

    this.http.post('https://upload.uploadcare.com/base/', data)
        .subscribe(event => {
          console.log(event)
          this.imageURL = event.json().file
        })
  }
}

我希望数据库云防火墙会提到注册用户上传的具体信息

typescript firebase ionic-framework google-cloud-firestore
1个回答
1
投票

这是一个正式的问题,因为您的应用程序被阻止由firebase自己发送数据,您应该允许您的应用程序写入和读取数据。作为一个快速解决方案,你应该去,

  Database tab in your relevant database--->select which type of DB yu are using
 -->Rules tab on the top column ,

在那里你会看到一小段代码说明:'false'和写'false',使它们都为'true'并应用更改并保存它们。它应该让它工作。如果它不让我知道

© www.soinside.com 2019 - 2024. All rights reserved.