Skip to content

Instantly share code, notes, and snippets.

@javebratt
Last active September 13, 2017 19:12
Show Gist options
  • Save javebratt/d249bd05e3aa6b0b63e9ab0c9d06ff16 to your computer and use it in GitHub Desktop.
Save javebratt/d249bd05e3aa6b0b63e9ab0c9d06ff16 to your computer and use it in GitHub Desktop.
Firebase Storage example
// 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