title: Pushing Firebase storage download URLs to Firebase cloud Firestore
body: <p>How can I push the download URL of Firebase storage files to the Firestore cloud? I have a project that can upload PDF files to Firestore storage, but I can't push the download URL of the uploaded files to the Firestore cloud.</p>
  
  <p>I need to catch the upload URL for every single file and send it to the document in the firestore to be able to download it. I'm uploading and downloading PDF files.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class pdfUploader extends AppCompatActivity {
      private StorageReference mStorageRef;
      Button upload;
      Button select;
      int CODE=215;
      private CollectionReference dbFirestore;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_pdf_uploader);
          mStorageRef = FirebaseStorage.getInstance().getReference();
          upload = findViewById(R.id.upload);
          select = findViewById(R.id.choose);
          select.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  selectFile();
              }
          });
      }
  
      public void selectFile () {
          Intent i = new Intent(Intent.ACTION_GET_CONTENT);
          i.setType("*/*");
          startActivityForResult(Intent.createChooser(i,"Select a file"), CODE);
      }
  
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          String filePath = data.getDataString();
          Uri SelectedFileLocation=Uri.parse(filePath);
          UploadFile(SelectedFileLocation);
          super.onActivityResult(requestCode, resultCode, data);
      }
  
      public  void UploadFile( Uri file) {
          Toast.makeText(this, "Please wait.. the file is uploading!", Toast.LENGTH_SHORT).show();
          //Uri file = Uri.fromFile(new File("path/to/images/rivers.jpg"));
          StorageReference riversRef = mStorageRef.child(Objects.requireNonNull(file.getLastPathSegment()));
          riversRef.putFile(file)
              .addOnSuccessListener(new OnSuccessListener&lt;UploadTask.TaskSnapshot&gt;() {
                  @Override
                  public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                      Toast.makeText(pdfUploader.this, "Upload Success", Toast.LENGTH_SHORT).show();
                  }
              }).addOnFailureListener(new OnFailureListener() {
                  @Override
                  public void onFailure(@NonNull Exception exception) {
                      Toast.makeText(pdfUploader.this, "Upload Failed", Toast.LENGTH_SHORT).show();
  
                  }
              });
      }
  }
  </code></pre>