In Storage need to create a folder for each post and then display all the photos from the folder in posts
Can you suggest the best way to do this? And also when the post is deleted, it is necessary to delete the folder with the photo too
Maybe you have some examples
const [posts, setPosts] = useState([]);
const [image , setImage] = useState("");
const [url , setUrl] = useState("");
const storage = getStorage();
//upload function
const upload = ()=>{
const storageRef = ref(storage, `images/${posts.id}/${image.name}`);
if(image == null) return;
uploadBytes(storageRef, image).then(() =>{
getDownloadURL(storageRef).then((url) => {
setUrl(url);
})
})
}
<input name='images' type="file" className="light" onChange={(e)=>{setImage(e.target.files[0])}}/>