Firebase 云存储权限被拒绝问题
Firebase Cloud Storage Permission denied issue
我一开始遇到的只是显示存储内容的问题。错误消息是相同的代码 400 "Permission denied. Could not access bucket bucket. Please enable Firebase Storage for your bucket by visiting the Storage tab in the Firebase Console and ensure that you have sufficient permission to properly provision resources."
但是我根据 所做的更改使问题变得更糟,现在我的上传表单出现了同样的错误并阻止了文件上传,即使在回滚所有更改之后也是如此。我尝试在 Firebase 上创建一个全新的项目,但它有同样的错误。
我还尝试将我的存储桶权限设置为
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read;
allow write;
}
}
}
因为我认为这可能是一个权利问题,但我得到了同样的错误。
我不确定添加这段代码时我想做什么,但我添加了
{ provide: StorageBucket, useValue: 'bucket' }
致我的提供者:在我的 app.module 上。我认为它是某物的占位符,我忘记在提交项目之前将其删除。
这让我失望并找到了有趣的故障排除路径,最终导致我执行断点和控制台日志,直到找到问题。
const task = this.storage.upload(filePath, file);
我做了 task 的控制台日志,它给了我一个位置,那是我找到
的地方
bucket: bucket
然后我将相同的 console.log 添加到显示
的工作项目中
bucket: whatever.appspot.com
而且我知道我在某处犯了错误。我刚刚在 app.module.ts 文件中尝试重现问题时偶然发现了这个条目。错误已解决。
我一开始遇到的只是显示存储内容的问题。错误消息是相同的代码 400 "Permission denied. Could not access bucket bucket. Please enable Firebase Storage for your bucket by visiting the Storage tab in the Firebase Console and ensure that you have sufficient permission to properly provision resources."
但是我根据
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read;
allow write;
}
}
}
因为我认为这可能是一个权利问题,但我得到了同样的错误。
我不确定添加这段代码时我想做什么,但我添加了
{ provide: StorageBucket, useValue: 'bucket' }
致我的提供者:在我的 app.module 上。我认为它是某物的占位符,我忘记在提交项目之前将其删除。
这让我失望并找到了有趣的故障排除路径,最终导致我执行断点和控制台日志,直到找到问题。
const task = this.storage.upload(filePath, file);
我做了 task 的控制台日志,它给了我一个位置,那是我找到
的地方 bucket: bucket
然后我将相同的 console.log 添加到显示
的工作项目中 bucket: whatever.appspot.com
而且我知道我在某处犯了错误。我刚刚在 app.module.ts 文件中尝试重现问题时偶然发现了这个条目。错误已解决。