0

I have tried all options I can to fix this code but nothing works for days.

I have this code that was made with firebase storage version 15.0.2 before getDownloadUrl() got deprecated

String imageTitle = ImageUtil.generateImageTitle(UploadImagePrefix.PROFILE, profile.getId());
        UploadTask uploadTask = databaseHelper.uploadImage(imageUri, imageTitle);

        if (uploadTask != null) {
            uploadTask.addOnCompleteListener(task -> {
                if (task.isSuccessful()) {
                    Uri downloadUrl = task.getResult().getDownloadUrl();
                    LogUtil.logDebug(TAG, "successful upload image, image url: " + String.valueOf(downloadUrl));

                    profile.setPhotoUrl(downloadUrl.toString());
                    createOrUpdateProfile(profile, onProfileCreatedListener);

                } else {
                    onProfileCreatedListener.onProfileCreated(false);
                    LogUtil.logDebug(TAG, "fail to upload image");
                }

            });

I don't know how to re edit this code to work with the latest version, every from I try to change to the latest Storage reference, I get error

I am politely asking for help, I will be grateful

  • Take a look at this [question](https://stackoverflow.com/questions/50467814/tasksnapshot-getdownloadurl-is-deprecated). `getDownloadUrl` returns a task, if you want to get the actual url you can add a success listener to that task. – Tyler V Sep 15 '21 at 00:54

0 Answers0