【问题标题】:Firebase Storage: Getting Permission denied 400 for public storageFirebase 存储:获取公共存储的权限被拒绝 400
【发布时间】:2018-10-26 09:59:15
【问题描述】:

我正在尝试使用 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;
    }
  }
}

【问题讨论】:

标签: android firebase google-cloud-firestore


【解决方案1】:

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

附注: Firebase 存储存在权限问题的各种报告。 Firebase 存储服务帐户被错误地从存储桶中删除,这导致请求最近出现错误。 Here's 链接。

步骤:

  • 转到Google Cloud Console.
  • 导航到存储。
  • 选择您的存储桶,然后点击显示信息面板。

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

【讨论】:

  • 干杯人,很高兴帮助..这个问题还没有解决,所以如果您遇到任何该问题的实例,您可以手动添加权限。我为这个问题提供的链接中也提到了它。
猜你喜欢
  • 1970-01-01
  • 2019-07-26
  • 2017-10-29
  • 1970-01-01
  • 2021-12-30
  • 1970-01-01
  • 1970-01-01
  • 2018-10-21
相关资源
最近更新 更多