Last active
September 13, 2017 19:12
-
-
Save javebratt/d249bd05e3aa6b0b63e9ab0c9d06ff16 to your computer and use it in GitHub Desktop.
Firebase Storage example
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
// Create a reference to Firebase Storage | |
this.driverProfilePictureRef = firebase.storage().ref('/driverProfilePicture/'); | |
// Upload the picture to Firebase Storage | |
const uploadPicture = this.driverProfilePictureRef.child("driver's id") | |
.child('profilePicture.png').putString(pictureInBase64StringHere, 'base64', {contentType: 'image/png'}); | |
// After the picture successfully uploads, you'll want to add that picture's url to the drivers node | |
uploadPicture.then( profilePicture => { | |
firebase.database().ref("path to the drivers node").child("driver id").child('profilePicture') | |
.set(profilePicture.downloadURL); | |
}); | |
} | |
// Then you can use it in the html | |
<img [src]="driver.profilePicture" /> | |
// This assuming that driver is the driver object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment