我正在尝试将downloadUrl上传到Firebase数据库。我使用了下面的代码。
在android studio Log上没有问题,但是该网址无法上传到Firebase数据库,因此我认为以下4行应予修改,但我不知道如何解决。
val map = HashMap<String, Any>()
map["image"] = url
FirebaseFirestore.getInstance()
.collection("profileImages")
.document(uid)
.set(map)
所以请帮助我。以下是“登录Android Studio”,其中包含来自Firebase存储的网址。
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 { task ->
val url = task.storage.downloadUrl.addOnSuccessListener { uri ->
Log.d("★★★★★★★★11111", uri.toString())
}
.toString()
val map = HashMap<String, Any>()
map["image"] = url
FirebaseFirestore.getInstance()
.collection("profileImages").document(uid)
.set(map)
}
}
}
在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:641) 在java.lang.Thread.run(Thread.java:919) 在com.bumptech.glide.load.engine.executor.GlideExecutor $ DefaultThreadFactory $ 1.run(GlideExecutor.java:446) D /★★★★★★★★★11111:https://firebasestorage.googleapis.com/v0/b/myapplication3-1f7fb.appspot.com/o/userProfileImages%2FNXHNuvKNmsOYjI7TRTMQDHxcCWf2?alt=media&token=e6e375cb-2337-4a5a-926b-e11ddac33a08 V / FA:不活动,正在与服务断开连接