如何从以下代码获取downloadurl?

时间:2019-10-02 16:14:51

标签: kotlin

下面是我检查过的代码,它没有工作。

我没有收到网址,但收到了“ com.google.android.gms.tasks.zzu@ffbfff5”

我认为

val url=taskSnapshot.getMetadata()?.getReference()?.getDownloadUrl()?.toString() 

应该修改,但我不知道如何解决。

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

        if (requestCode == PICK_PROFILE_FROM_ALBUM && resultCode == Activity.RESULT_OK) {
            var imageUri = data?.data
            val uid = FirebaseAuth.getInstance().currentUser!!.uid 

            FirebaseStorage
                .getInstance()
                .reference
                .child("userProfileImages")
                .child(uid)
                .putFile(imageUri!!)
                .addOnSuccessListener { taskSnapshot ->
                    val url = taskSnapshot.getMetadata()?.getReference()?.getDownloadUrl()?.toString()
                    val map = HashMap<String, Any>()
                    map["image"] = url
                    FirebaseFirestore.getInstance().collection("profileImages").document(uid).set(map)
                }
        }
    }
}

0 个答案:

没有答案