I am trying to store the url in the firebasedatabase of images i upload into the firebase storage.
I have tried some video guides but most of them are outdated.I am trying to use downloadUrl to fetch url but its not working. I am new to coding and i d appreciate any kind of advice. I have tried Firebase Documentation but i am unable to apply it into my code.
if (mImageUri != null) { val fileName= edit_text_file_name.text.toString() val fileReference = mStorageRef!!.child(fileName + "." + getFileExtension(mImageUri!!) ) mUploadTask = fileReference.putFile(mImageUri!!) .addOnSuccessListener { taskSnapshot -> val name = taskSnapshot.metadata!!.name val imageUrl= taskSnapshot.metadata!!.reference!!.downloadUrl.toString() The problem here is in the line above i think with val imageUrl
writeNewImageInfoToDB(name!!, imageUrl) Toast.makeText(this@ActivityUpload, "Upload successful", Toast.LENGTH_LONG).show() } .addOnFailureListener { e -> Toast.makeText(this@ActivityUpload, e.message, Toast.LENGTH_SHORT).show() } .addOnProgressListener { taskSnapshot -> val progress = (100.0 * taskSnapshot.bytesTransferred / taskSnapshot.totalByteCount) mProgressBar!!.progress = progress.toInt() } I expect the above code to give me the URL of the image i uploaded but instead i get
com.google.android.gms.tasks.zzu@5a826e5" in my database whereas i am expecting a firebase url like firebasestorage.googleapis.com/v0/b/-------`