I tried to get download Url from Firebase Cloud Storage and save back to Database but after successful file upload to Storage I was getting very strange URL value when I tried to add URL into DB.
final String uid = task.getResult().getUser().getUid();
FirebaseStorage.getInstance().getReference().child("userImages").child(uid).putFile(imageUri).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
//String imageUrl = task.getResult().getStorage().getDownloadUrl().toString();
String imageUrl = task.getResult().getStorage().getDownloadUrl().toString();
UserModel usermodel = new UserModel();
usermodel.uesrName = name.getText().toString();
usermodel.ProfileImageURL = imageUrl;
Toast.makeText(RegisterActivity.this,imageUrl,Toast.LENGTH_LONG);
FirebaseDatabase.getInstance().getReference().child("user").child(uid).setValue(usermodel);
}
});
From the Storage I can't find URL information but I could find token
From the DB URL name was very strange and I could see the same name in imageUrl.