Created
December 26, 2016 15:20
-
-
Save javebratt/a4728ec8b8a034c4fe5eba1d27eb01d5 to your computer and use it in GitHub Desktop.
Quick example of uploading and retrieving images from Firebase storage.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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