Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private fun uploadImageToFirebase(){
- if (selectedPhotoUri == null) return
- val filename = UUID.randomUUID().toString()
- val ref = FirebaseStorage.getInstance().getReference("/images/$filename")
- ref.putFile(selectedPhotoUri!!)
- .addOnSuccessListener { it ->
- Log.d("Main","Successfully uploaded image: ${it.metadata?.path}")
- ref.downloadUrl.addOnSuccessListener {
- it.toString()
- Log.d("Main", "File location: $it")
- saveUserToFirebaseDatabase(it.toString())
- }
- }
- .addOnFailureListener{
- Log.d("Main", "Failed to upload image")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement