Problems in getDownloadUrl firebase

0

Hello, I have a difficulty in the getDownloadUrl firebase.

After the last firebase storage update my app stopped working.

You are experiencing an error in Uri downloadUrl = taskSnapshot.getDownloadUrl ();

        uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                Uri downloadUrl = taskSnapshot.getDownloadUrl();

                Map newImage = new HashMap();
                newImage.put("profileImageUrl", downloadUrl.toString());
                mCustomerDatabase.updateChildren(newImage);

                finish();
                return;
            }
        });

Displays error

    
asked by anonymous 16.08.2018 / 23:14

1 answer

0

This method has been removed in favor of StorageReference.getDownloadUrl() . This method returns a Task<Uri> . So you have to add a listener to Task to get the downloadUrl:

uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                    @Override
                    public void onSuccess(Uri downloadUrl) {

                        Map newImage = new HashMap();
                        newImage.put("profileImageUrl", downloadUrl.toString());
                        mCustomerDatabase.updateChildren(newImage);

                        finish();
                    }
                });

            }
        });
    
17.08.2018 / 00:26