I have a website that has cards in grid with image inside and title for example
and I want to get a list of images from firebase storage, the problem is if I store the same image file my other image files with the same image are broken,
How I can get a list of images from firebase storage. Or what is the best way to store image file with combine firebase database my code to add new card is like this I store the image metadata download URL
const storageRef = firebase.storage().ref();
for (let selectedFile of [(<HTMLInputElement>document.getElementById('image')).files[0]]){
let path = `/${this.prosforesFolder}/${selectedFile.name}`;
let iRef = storageRef.child(path);
iRef.put(selectedFile).then((snapshot) => {
prosfora.imageUrl = snapshot.downloadURL;
prosfora.image = selectedFile.name;
prosfora.path = path;
// firebase.database().ref('/listings').push(listing);
return this.prosfores.push(prosfora);
});
}
but what I get is if I store 6 files with the same image file name only the last image can render the other 5 is broken
to get the images from fire base I just cal this function
// gets the list of ypiresies
this.firebaseService.getProsfores().subscribe(prosfores => {
this.prosfores = prosfores;
if (prosfores.length > 0) {
this.prosforesExist = true;
} else {
this.prosforesExist = false;
}
console.log(prosfores);
// afto kanei hide to preloader
$( ".preloader-wrapper" ).hide();
$(document).ready(function(){
$('.gallery-expand').galleryExpand({
// dynamicRouting : true
// defaultColor: 'red'
// fillScreen : 'true'
});
});
});
What I do wrong, there is any way that I can change the file name before I upload the file on firebase storage ???
like image.png image-v2.png image-v3.png
How I can do that ??
Any Help is gonna be welcome