I am trying to retrieve an image from my firebase storage but I'm having problems storing the image download url. I am using final String downloadUrl = task.getResult().getMetadata().getReference().getDownloadUrl().toString();
but this is only reutrning a reference to the task I believe - com.google.android.gms.tasks.zzu@add13a0
What I want to be storing/retrieving is https://firebasestorage.googleapis.com/v0/b/chat-poll-application.appspot.com/o/Group%20Images%2FGig.jpg?alt=media&token=9a90fc94-e65f-4ace-9259-aaaa91b449c3
Can anyone see where I'm going wrong?
Here is the full code:
filePath.putFile(resultUri).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
if (task.isSuccessful()) {
Toast.makeText(GroupSettingsActivity.this, "Group image uploaded successfully", Toast.LENGTH_SHORT).show();
final String downloadUrl = task.getResult().getMetadata().getReference().getDownloadUrl().toString();
RootRef.child("Groups").child(currentGroupName).child("Image").setValue(downloadUrl)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(GroupSettingsActivity.this, "Image saved successfully", Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
} else {
String message = task.getException().toString();
Toast.makeText(GroupSettingsActivity.this, "Error: " + message, Toast.LENGTH_SHORT).toString();
loadingBar.dismiss();
}
}
});
} else {
String message = task.getException().toString();
Toast.makeText(GroupSettingsActivity.this, "Error " + message, Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
}
}
});
Here is my database: