My Database is Like this:
UID -> Image, name, email,
And when a picture is posted it has a name, and if i put the same name on a new picture it overwrites the older one.. I wanted it to create a new one on the storage...
Here is my code to upload the files to storage and database:
createHomePost(pictureName: string, picture: string, username, email): firebase.Promise<any> {
firebase.storage().ref('/homePictures/').child(pictureName)
.child('picture.jpg')
.putString(picture, 'base64', { contentType: 'image/jpg' })
.then((savedPicture) => {
this.HbRef.push({
picture: savedPicture.downloadURL,
name: pictureName,
username: firebase.auth().currentUser.displayName,
email: firebase.auth().currentUser.email
})
});
return
}
Thanks in advance.