-1

error screenshot

I tried to get a download URL like this but it is not getting correct URL. I am a beginner in Firebase, how can I do it?

Jake Lee
  • 6,487
  • 8
  • 43
  • 76
Sampath
  • 1
  • 4

2 Answers2

2

You can get the download URL like this

fileRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {

     @Override
     public void onSuccess(Uri uri) {
        final Uri download_url = uri;
     }
}):
Rohit Singh
  • 14,672
  • 7
  • 83
  • 77
Ashwith Saldanha
  • 1,294
  • 1
  • 4
  • 13
0

You can get your download path after uploading the file as follows (you need to call a second method on your reference object (getDownloadUrl):

    profilePicUploadTask = fileRef.putFile(imgUrl).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() 
    {
        @Override
        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot)
        {
             // note: you can get the download path only after the file is uploaded successfully. 
             // To get the download path you have to call another method like follows:
             fileRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() 
             {
                @Override
                public void onSuccess(Uri uri) 
                {
                   // uri is your download path
                }
        }
    });
kAliert
  • 748
  • 10
  • 21