Chris Martinez
Chris Martinez

Reputation: 89

How would I reference an image in firebase storage?

How would I go about referencing an image in firebase storage? I'm trying to embed it into my html in an img tag. Thanks for any help!

Upvotes: 0

Views: 1372

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598847

You'd typically use a so-called download URL for that. From the Firebase documentation on getting a download URL:

storageRef.child('images/stars.jpg').getDownloadURL().then(function(url) {
  // Get the download URL for 'images/stars.jpg'
  // This can be inserted into an <img> tag
  var img = document.createElement('img');
  img.setAttribute('src', url);
  document.body.appendChild(img);
}).catch(function(error) {
  console.error(error);
});

Upvotes: 1

Related Questions