Error: cannot find symbol method getDownloadUrl() of type com.google.firebase.storage.UploadTask.TaskSnapshot

后端 未结 7 870
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 07:28

Before gradle update everything worked fine, but later on this error popped up. I have referred to the official documents and it provides the same code. Not accepting the ge

7条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 08:04

    For kotlin

    val uploadTask = fileReference.putFile(Uri.fromFile(primaryFile), metadata)
    

    and

            uploadTask
                    .addOnProgressListener { taskSnapshot ->
    
                    }
    
                    .addOnPausedListener { 
    
                    }
    
                    .addOnSuccessListener { taskSnapshot ->
                    }
                    .continueWithTask { task ->
                        if (!task.isSuccessful) {
                            throw task.exception!!
                        }
                     fileReference.downloadUrl
                    }
    
                    .addOnCompleteListener { task ->
    
                        if (task.isSuccessful) {
                            val downloadUrl: Uri = task.result
    
                        } else {
                            // Handle failures
                        }
                    }
    
                    .addOnFailureListener { e ->
    
                    }
    

    val downloadUrl is your URL that is uploaded.

提交回复
热议问题