Код: Выделить всё
fun uploadImage(userName: String, uri: Uri): String
{
uploadImageProcess(userName , uri)
return downloadUri
}
private fun uploadImageProcess(userName: String, uri: Uri){
val ref = createReference(userName)
Log.d("uploadImageFUNCTION", "Reference: $ref")
val uploadTask = ref.putFile(uri)
val urlTask = uploadTask.continueWithTask { task ->
if (!task.isSuccessful) {
task.exception?.let {
Log.d("uploadImageFUNCTION", "task upload .exception: $task.exception")
throw it
}
}
ref.downloadUrl
}.addOnCompleteListener { task ->
if (task.isSuccessful) {
Log.d("uploadImageFUNCTION", "task downloadUrl : ${task.result}")
downloadUri = task.result.toString()
} else {
Log.d("uploadImageFUNCTION", "task downloadUrl .exception: $task.exception")
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... -in-kotlin
Мобильная версия