Я получаю сообщение об ошибке Когда я пытаюсь загрузить файл с AngularFireStorage и с правилом разрешения чтения, напишите: if request.auth! = Null; - PullRequest
0 голосов
/ 09 октября 2019

Любая помощь, пожалуйста! я получаю сообщение об ошибке при попытке загрузить файл с AngularFireStorage Даже если я уже идентифицирован в приложении с аутентификацией firebase

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write: if request.auth != null;
    }
  }
}

Моя функция загрузки

 upload(event){
    this.ImgError = "";
    const id = event.target.files[0].name;
    this.ref = this.afStorage.ref(id);
    var ImgType = event.target.files[0].type.split('/')[0];    
    if(ImgType !== 'image') {
      this.ImgError = "Désolé, invalide image";
      return;
    }
    if(event.target.files[0]){
      this.imagePath = '../../../assets/img/loading.gif';
      this.ref.put(event.target.files[0])
      .then(snapshot => {
          return snapshot.ref.getDownloadURL();   // Will return a promise with the download link
      })
      .then(downloadURL => {
         this.imagePath = downloadURL;
         return downloadURL;
      })
      .catch(error => {
        this.ImgError = "Une Erreur lors de la téléchargement de l'image";
      });
    }
  }

Ошибка, которую я получаю

{
  "error": {
    "code": 403,
    "message": "Permission denied. Could not perform this operation"
  }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...