1
通過Firebase存儲上傳文件時,onSuccess方法未調用。Firebase存儲的OnSuccessListener回調未調用
我目前使用'com.google.firebase:firebase-storage:10.2.6'運行Android Studio 3.0 Canary 2。
fun uploadImage(pathToImage: String, downloadCallback: FirebaseCallback<String?>) {
val file = Uri.fromFile(File(pathToImage))
val ref = mStorRef.child("images/"+file.lastPathSegment)
ref.putFile(file).addOnSuccessListener {
object : OnSuccessListener<UploadTask.TaskSnapshot> {
override fun onSuccess(taskSnapshot: UploadTask.TaskSnapshot?) {
val url = taskSnapshot?.downloadUrl
Log.d("FirebaseManager", "Upload Successful")
downloadCallback.callback(url.toString())
}
}
}
}