taskSnapshot.getDownloadUrl() method not working

后端 未结 23 754
有刺的猬
有刺的猬 2020-12-08 08:03
private void uploadImageToFirebaseStorage() {
    StorageReference profileImageRef =
        FirebaseStorage.getInstance().getReference(\"profilepics/\" + System.cur         


        
相关标签:
23条回答
  • 2020-12-08 08:39

    For Java Code

    String downloadUrl = taskSnapshot.getMetadata().getReference().getDownloadUrl().toString();
    

    For Kotlin

    val downloadUrl = taskSnapshot.getMetadata()?.getReference()?.getDownloadUrl()?.toString()
    
    0 讨论(0)
  • 2020-12-08 08:42

    I faced the similar error I solved it with this method. Hope it helps

    uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                @Override
                public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                    Task<Uri> task = taskSnapshot.getMetadata().getReference().getDownloadUrl();
                    task.addOnSuccessListener(new OnSuccessListener<Uri>() {
                        @Override
                        public void onSuccess(Uri uri) {
                            String photoLink = uri.toString();
                            Map userInfo = new HashMap();
                            userInfo.put("profileImageUrl", photoLink);
                            mUserDatabase.updateChildren(userInfo);
                        }
                    });
                    finish();
                    return;
                }
            });
    
    0 讨论(0)
  • 2020-12-08 08:44

    you can also use Picasso dependencies . its easy to use for uploading image in firebase.

    ActivityFile:

     Picasso.get().load(uriImage).into(ImageUri);
    

    app-gradle:

    com.squareup.picasso:picasso:2.71828
    
    0 讨论(0)
  • 2020-12-08 08:45

    Use Firebase storage version 15.0.0.

    Uri downloadUrl=taskSnapshot.getDownloadUrl().toString();
    
    0 讨论(0)
  • 2020-12-08 08:45

    I still having this error. What might be wrong? I already changed the permissions, and users to anonymous.

    0 讨论(0)
  • 2020-12-08 08:46

    Try Using this it will download the image from FireBase storage

    FireBase Libraries versions 16.0.1

    Task<Uri> result = taskSnapshot.getMetadata().getReference().getDownloadUrl();
    result.addOnSuccessListener(new OnSuccessListener<Uri>() {
          @Override
          public void onSuccess(Uri uri) {
                 String photoStringLink = uri.toString();
          }
    });
    
    0 讨论(0)
提交回复
热议问题