SHARE
TWEET

Untitled

a guest Jul 16th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private fun uploadImageToFirebase(){
  2.         if (selectedPhotoUri == null) return
  3.         val filename = UUID.randomUUID().toString()
  4.         val ref = FirebaseStorage.getInstance().getReference("/images/$filename")
  5.         ref.putFile(selectedPhotoUri!!)
  6.             .addOnSuccessListener { it ->
  7.                 Log.d("Main","Successfully uploaded image: ${it.metadata?.path}")
  8.  
  9.                 ref.downloadUrl.addOnSuccessListener {
  10.                     it.toString()
  11.                     Log.d("Main", "File location: $it")
  12.  
  13.                     saveUserToFirebaseDatabase(it.toString())
  14.                 }
  15.             }
  16.             .addOnFailureListener{
  17.                 Log.d("Main", "Failed to upload image")
  18.             }
  19.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top