Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot resolve getDownloadUrl please help me out here is the code #53

Open
nandhyalasai opened this issue Dec 2, 2018 · 4 comments
Open

Comments

@nandhyalasai
Copy link

public void createOrUpdateProfileWithImage(final Profile profile, Uri imageUri, final OnProfileCreatedListener onProfileCreatedListener) {
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();  //problem here
                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");
            }

        });
@real-habibul
Copy link

somebody, please notice this.. hehe

@fabiorbap
Copy link

+1

@juandgaines
Copy link

Hi! you can replace it with this according to the firebase documentation:
`Uri selectedImageUri=data.getData();

        final StorageReference photoRef=
                mChatPhotosStorageReference.child(selectedImageUri.getLastPathSegment());

        photoRef.putFile(selectedImageUri).continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
            @Override
            public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
                if (!task.isSuccessful()) {
                    throw task.getException();
                }

                // Continue with the task to get the download URL
                return photoRef.getDownloadUrl();
            }
        }).addOnCompleteListener(new OnCompleteListener<Uri>() {
            @Override
            public void onComplete(@NonNull Task<Uri> task) {
                if (task.isSuccessful()) {
                    Uri downloadUri = task.getResult();
                    FriendlyMessage friendlyMessage= new FriendlyMessage(null,mUsername,downloadUri.toString());
                    mMessagesDatabaseReference.push().setValue(friendlyMessage);
                } else {
                    // Handle failures
                    // ...
                }
            }
        });`

@gabrielohdez
Copy link

have you found the solution ?, help me please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants