0

FireBase Storage Layout:

image

How do I get my downloadURl to successfully download and upload an image in Firebase storage. When I run the code below, I always seem to end at addOnFailureListener.

val storageRef = FirebaseStorage.getInstance().reference.child("image/Calendar.png")

storageRef.downloadUrl.addOnSuccessListener { uri ->
        Picasso.with(applicationContext).load(uri.toString()).into(image)
        Toast.makeText(applicationContext, uri.toString(), Toast.LENGTH_LONG).show()
    }.addOnFailureListener(){
        Toast.makeText(applicationContext, "fail", Toast.LENGTH_LONG).show()
}
itsmysterybox
  • 2,748
  • 3
  • 21
  • 26
  • The failure listener is passed an argument that has some error message in it, but you're not using it. You should examine it to see what it says. – Doug Stevenson Nov 02 '18 at 17:11
  • How do I access the error message in FailureListener if that is what u mean? – Jonas Lim Nov 02 '18 at 17:26
  • Thanks man! I tried debugging and checking under the addOnfailurelistener, i was able to figure out that it was due to "user does not have permission to access object" For future reference, is that a way i can return the read the error message apart from thru debugging? – Jonas Lim Nov 02 '18 at 17:36
  • I had my bucket name set wrongly. This thread helped https://stackoverflow.com/questions/38671444/user-does-not-have-permission-to-access-this-object-firebase-storage-android – Jonas Lim Nov 02 '18 at 17:37

0 Answers0