-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
  • 7,549
  • 8
  • 45
  • 86
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
  • 16,950
  • 7
  • 90
  • 88
Ashwith Saldanha
  • 1,700
  • 1
  • 5
  • 15
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
  • 768
  • 9
  • 21