Android Firebase存储:获取公共存储的权限被拒绝

Android Firebase存储:获取公共存储的权限被拒绝,android,firebase,google-cloud-firestore,Android,Firebase,Google Cloud Firestore,我正在尝试从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

我正在尝试从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!!!!");
  }
});

我认为这是由于您的谷歌云控制台中缺少权限所致。您需要检查是否有firebase-storage@system.gserviceaccount.com作为存储管理员。如果你没有,那就加上它。它解决了我的问题

p.S.:关于Firebase存储的权限问题,有各种报告。Firebase存储服务帐户被错误地从存储桶中删除,这会导致最近的请求出现错误。链接

步骤:

  • 导航到存储
  • 选择您的存储桶,然后单击“显示信息”面板

添加缺少的权限。如果需要,您还可以在IAM&Admin中添加缺少的权限。

干杯,很乐意帮助。。该问题尚未解决,因此如果遇到该问题的任何实例,请手动添加权限。它也提到了我给这个问题的链接
// 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;
    }
  }
}