android - Firebase 存储:获取公共存储的权限被拒绝 400
问题描述
我正在尝试使用 Android 应用程序中的 Firebase 存储。一开始一切都很好。现在我得到回应:
{
"error": {
"code": 400,
"message": "Permission denied. Could not access bucket adiglehard.appspot.com. 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."
}
}
上传代码为:
storage = FirebaseStorage.getInstance("gs://adiglehard.appspot.com/");
Uri file = Uri.fromFile(new File(mFile.getAbsolutePath()));
StorageReference storageRef = storage.getReference();
StorageReference riversRef = storageRef.child("images/" + file.getLastPathSegment());
uploadTask = riversRef.putFile(file);
// Register observers to listen for when the download is done or if it fails
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle unsuccessful uploads
showToast("error!!!!");
exception.printStackTrace();
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
showToast("success!!!!");
}
});
Firestore 规则是:
// Anyone can read or write to the bucket, even non-users of your app.
// Because it is shared with Google App Engine, this will also make
// files uploaded via GAE public.
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write;
}
}
}
解决方案
推荐阅读
- angular - 类型 jQuery 上不存在属性 src
- reactjs - 如何在 React 中使用 Formik 的自定义输入?
- sql - 如何在sql server的where子句中应用case?
- sharepoint - 在共享点服务器中使用 Microsoft.office.interop.word
- .net - 非域计算机上的 Set-ADComputer
- visual-studio - VS2017 和 GTX 870M 的 CUDA 版本是什么?
- python - 弹性搜索词聚合中的问题
- networking - 有没有办法将 ping (icmp) 数据包转换为 TCP 数据包?
- c++ - 模板显式特化的 C++ 措辞
- c# - 使用 Castle 动态代理进行异步拦截