【问题标题】:Firebase error when trying to get a file download url from firebase尝试从 firebase 获取文件下载 url 时出现 Firebase 错误
【发布时间】:2020-07-21 12:00:18
【问题描述】:

我正在尝试上传图像文件并使用此代码获取图像下载 URL

    private void UploadImage() {
    String storageFileName = System.currentTimeMillis() + ".jpg"; // Time is used to ensure unique file name
    FireBase_File = FireBase_Storage.child(storageFileName);

    FireBase_File.putFile(UriBitmap).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
        @Override
        public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
            if(task.isSuccessful()) {
                FireBase_File.getDownloadUrl().addOnCompleteListener(new OnCompleteListener<Uri>() {
                    @Override
                    public void onComplete(@NonNull Task<Uri> task) {
                        if(task.isSuccessful()) {
                            FireBase_DownloadURL = task.getResult().toString();
                        } else { Log.e(Global.Log_Tag + "Manage_Restaurant/UploadImage", "Failed to get download url [Exception]" + task.getException()); }
                    }
                });
            } else { Log.e(Global.Log_Tag + "Manage_Restaurant/UploadImage", "Failed to upload image [Exception]" + task.getException()); }

            Finish_End();
        }
    });
}

直到昨天我开始在控制台中收到此错误消息时它工作正常

E/StorageUtil:获取令牌时出错 java.util.concurrent.ExecutionException:com.google.firebase.internal.api.FirebaseNoSignedInUserException:请先登录,然后再尝试获取令牌。

现在我知道在here 之前已经问过这个问题,但我尝试了这个线程建议的所有内容,但它不起作用。还值得注意的是,我没有使用 auth firebase 系统。我尝试使用匿名登录建议,但它给了我这个错误。

com.google.firebase.auth.FirebaseAuthException:此操作仅限于管理员。

感谢所有回复!

【问题讨论】:

  • 您是否在 Firebase 控制台中启用了匿名登录?
  • 我启用了它并且它有效!非常感谢,我不知道您需要激活它,因为我没有使用身份验证系统。编辑:我无法将此线程设置为已解决...所以我不知道该怎么办
  • 我已将其添加为答案

标签: android firebase android-studio firebase-realtime-database firebase-storage


【解决方案1】:

您必须为您的 Firebase 项目启用匿名身份验证:

在 Firebase 控制台中,Auth -> Sign-in Methods 启用 Anonymous 登录方法。

【讨论】:

    猜你喜欢
    • 2021-03-22
    • 2020-07-09
    • 2017-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-13
    • 2019-07-18
    • 2021-03-03
    相关资源
    最近更新 更多