title: AngularFire2 - Firebase storage getDownloadURL() - How to return the url for firestore
body: <p>I've been going through the angularfire2 documentation to retrieve a downloadURl from storage. I'm hoping I'm missing something simple here.</p>
  
  <p>The documentation states:</p>
  
  <pre><code>@Component({
    selector: 'app-root',
    template: `&lt;img [src]="profileUrl | async" /&gt;`
  })
   export class AppComponent {
     profileUrl: Observable&lt;string | null&gt;;
     constructor(private storage: AngularFireStorage) {
     const ref = this.storage.ref('users/davideast.jpg');
     this.profileUrl = ref.getDownloadURL();
   }
  }
  </code></pre>
  
  <p>However, once I've uploaded an image I want to return the download url as a string to upload to firestore. I need the download URL for an external service. </p>
  
  <p><strong>My function</strong></p>
  
  <pre><code>uploadImage(base64data) {
  
    const filePath = (`myURL/photo.jpg`);
    const storageRef = firebase.storage().ref();
  
    var metadata = {
      contentType: 'image',
      cacheControl: "public, max-age=31536000",
    };
  
    const ref = this.storage.ref(filePath);
    const task = ref.putString(base64data, 'data_url', metadata).then(() =&gt; {
  
      var downloadURL = ref.getDownloadURL();
  
    })
  
  }
  </code></pre>
  
  <p>This uploads the image perfectly fine. However, I would then like to write the download URL to firestore. When console logging my 'downloadURL' variable, I get the following:</p>
  
  <blockquote>
    <p>PromiseObservable {_isScalar: false, promise: y, scheduler: undefined}</p>
  </blockquote>
  
  <p>The download is inside the promise observable. How do I just get the download URL string as my variable? Once I have that I can sort the firestore updates out.</p>