Empecé a aprender firebase, así que necesito mapear y mostrar todas las imágenes de mi almacenamiento. Sé cómo descargar y mostrar solo una imagen con su ruta
const fireBaseApp = initializeApp(firebaseConfig); function App() { const [url, setUrl] = useState(); useEffect(() => { const func = async () => { const storage = getStorage(fireBaseApp); const download = ref(storage, "logo.png"); await getDownloadURL(download).then((x) => { setUrl(x); }); }; func(); }, []); return( <> <img src={url}/> </> ); }Entonces, ¿alguien puede explicarme cómo mapear todas las imágenes? Gracias !
Puede usar la función listAll() para enumerar todos los archivos en un directorio o ruta.
import { getStorage, ref, listAll } from "firebase/storage"; const storage = getStorage(); // Create a reference under which you want to list const listRef = ref(storage, '/'); // replace path if needed listAll(listRef) .then((res) => { res.items.forEach((itemRef) => { // All the items under listRef. // Can get download URL for each item here }); })