Firebase 存储错误:获取令牌时出错

Ach*_*aul 0 android firebase firebase-storage

我正在构建一个允许用户将图片上传到 firebase 存储的 android 应用程序。我仍处于开发模式,因此我将存储规则设置为公开。当用户选择要上传的图片时,不会上传文件,而是返回下载地址。Logcat 显示以下错误

E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
Run Code Online (Sandbox Code Playgroud)

这是我的存储规则

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

还有我的 android java 代码:

private void uploadPic() {
StorageReference mStorageRef = FirebaseStorage.getInstance().getReference();
        Uri fileUrl = Uri.fromFile(new File(filePath));
        String fileExt = MimeTypeMap.getFileExtensionFromUrl(fileUrl.toString());
        final String fileName = UUID.randomUUID().toString()+"."+fileExt;
        StorageReference profilePicsRef = mStorageRef.child("profile_pics/"+fileName);
        profilePicsRef.putFile(fileUrl)
                .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                    @Override
                    public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                        // Get a URL to the uploaded content
                        Uri downloadUrl = taskSnapshot.getDownloadUrl();
                      Log.d("DOWNLOAD_URL", downloadUrl.toString());

                    }
                })
                .addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception exception) {
                        // Handle unsuccessful uploads
                        // ...
                        Toast.makeText(getApplicationContext(), "Error: "+exception.toString(), Toast.LENGTH_LONG).show();

                    }
                });
}
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激。

更新

我已经缩小了问题的范围:我有两个存储文件夹,我可以上传到“Videos”文件夹,但不能上传到“profile_pics”文件夹或任何其他文件夹。为什么会这样?

Ach*_*aul 6

由于一些凡人不知道的原因,众神拒绝上传到任何以“profile”开头的文件夹。我不得不创建另一个文件夹“users_profile_pic”。浪费了三天!