title: How to get file URL after uploading them to Firebase?
body: <p>Once you have uploaded a file to Firebase how can you get it's URL so that you can store that for later use? I want to write the URL to a Firebase Database so that other users can access the image.</p>
  
  <p>I am uploading the file like so:</p>
  
  <pre><code>public void uploadFile()
  {
  
      StorageReference filepath = mstorageRef.child("folder").child(filename);
  
      Uri File= Uri.fromFile(new File(mFileName));
  
      filepath.putFile(File).addOnSuccessListener(new OnSuccessListener&lt;UploadTask.TaskSnapshot&gt;() {
          @Override
          public void onSuccess(UploadTask.TaskSnapshot taskSnapshot)
          {
              Toast.makeText(MtActivity.this, "Upload Done", Toast.LENGTH_LONG).show();
          }
      });
  }
  </code></pre>
  
  <p>I have confirmed that the files are in fact uploading so now I just need the URL which I can write to my Database. However when I tried to do this:</p>
  
  <pre><code>Uri downloadUrl = taskSnapshot.getMetadata().getDownloadUrl();
  </code></pre>
  
  <p>It gives me an error and says <code>This method should only be accessed from tests or within private scope</code></p>
  
  <p>I'm not sure what that means and I also don't know why I would be getting that error since I'm following <a href="https://firebase.google.com/docs/storage/android/upload-files" rel="noreferrer">this example</a> provided by Firebase.</p>
  
  <p>Is there a new way of getting the URL?</p>
  
  <p>Also, is that URL unique to that item in particular? Meaning if I store it to a database and try to access it later will I be able to do so?</p>