I am having a problem getting the url of my image in firebase storage. Basically, each time the url is something like -
com.google.android.gms.tasks.zzu@899c8a
Yes I know people had the same problem yet I couldn't fix it with the answers they approved. I tried the following -
String upload = sRef.child("users/"+uid+"/"+SetModule+"/note-"+randomString).getDownloadUrl().toString();
String upload = taskSnapshot.getMetaData().getDownloadUrl().toString();
String upload = taskSnapshot.getStorage().toString();
but without any success.
I know that getMetaData is deprecated and I should use getStorage but it still didn't work. Uploading to the storage works perfectly.
I am using com.google.firebase:firebase-storage:16.0.1
Below is my code -
final String randomString = getRandomString(6);
StorageReference storageReference = sRef.child("users/"+uid+"/"+SetModule+"/note-"+randomString);
storageReference.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
String upload = sRef.child("users/"+uid+"/"+SetModule+"/note-"+randomString).getDownloadUrl().toString();
myRef.child("users").child(uid).child("modules").child(SetModule).child("note-"+randomString).setValue(upload);
Log.d("MyTag","Upload Success");
}
});