Firebase error when trying to get a file download url from firebase

。_饼干妹妹 提交于 2021-01-28 06:01:16

问题


I'm trying to upload an image file and get the image download URL using this code

    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();
        }
    });
}

and it worked fine until yesterday when I started getting this error messages in the console

E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.

now I'm aware that this question has been asked before here but I tried everything this threads suggested and it's not working. it's also worth noting that I'm not using the auth firebase system. I tried using the login anonymously suggestion and it gave me this error.

com.google.firebase.auth.FirebaseAuthException: This operation is restricted to administrators only.

all replies are appreciated!


回答1:


You have to enable anonymous auth for your Firebase project:

In the Firebase Console, Auth -> Sign-in Methods enable the Anonymous sign-in method.



来源:https://stackoverflow.com/questions/61111453/firebase-error-when-trying-to-get-a-file-download-url-from-firebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!