Skip to content

Instantly share code, notes, and snippets.

@javebratt
Created December 26, 2016 15:20
Show Gist options
  • Save javebratt/a4728ec8b8a034c4fe5eba1d27eb01d5 to your computer and use it in GitHub Desktop.
Save javebratt/a4728ec8b8a034c4fe5eba1d27eb01d5 to your computer and use it in GitHub Desktop.
Quick example of uploading and retrieving images from Firebase storage.
// You create a reference for the picture:
this.profilePictureRef.child(newGuest.key).child('profilePicture.png')
// Then you upload it:
.putString(guestPicture, 'base64', {contentType: 'image/png'})
// Since it returns a promise, you save the downloadURL somewhere to use later:
.then((savedPicture) => {
this.eventList.child(eventId).child('guestList').child(newGuest.key).child('profilePicture')
.set(savedPicture.downloadURL);
});
// When you're going to use it you'll just need to retrieve that download URL and use it inside
// the `src` property of the `<img />` tag
`<img [src]="profilePicture" />`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment