上传或获取图像时出现 403 错误 - Firebase

403 Error While Uploading or Getting Images - Firebase

它在几天前工作,上传并显示图像到 firebase。但是现在每次上传都会给我错误代码 403

这是我在 firebase 中的存储规则:

service firebase.storage {
   match /b/{bucket}/o {
    match /{userId}/{postId}/{fileName} {
     allow write: if request.auth.uid == userId;
     allow read;
    }
  }
}

PS:用户在上传和显示图片时已登录。 也不让我上传图片

卡住了,需要帮助。

通过将存储规则更改为 public

自行解决

这不是一种安全的方法,但解决了我的错误:

service firebase.storage {
   match /b/your-app-name.appspot.com/o {
     match /{allPaths=**} {
      // Allow access by all users
      allow read, write;
     }
  }
}