‘Firebase Storage: An unknown error occurred, please check the error payload for server response. (storage/unknown)

I’m making a system to download media from a subfolder inside a main folder with javascript, but it keep showing me an error when I execute the code file, the error it keeps showing me is

)] {
  code: 'storage/unknown',
  customData: { serverResponse: '' },
  status_: 400,
  _baseMessage: 'Firebase Storage: An unknown error occurred, please check the error payload for server response. (storage/unknown)'
}

this shows when I execute the JS file directly.


//THIS IS MY connection.js

// firebaseConfig.js
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore"; // Mantener esta línea para Firestore
import { getStorage, ref, listAll, getDownloadURL } from "firebase/storage"; // Cambiado a 'firebase/storage'

// Your web app's Firebase configuration
const firebaseConfig = {
  apiKey: "",
  authDomain: "",
  databaseURL: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: "",
  appId: "",
  measurementId: ""
};

const app = initializeApp(firebaseConfig);
const storage = getStorage(app);

export { app, storage, ref, listAll, getDownloadURL };

//MY download.js

import fs from 'fs';
import path from 'path';
import { pool } from '../postgresconnection.js'; // Conexión a PostgreSQL
import { storage, ref, listAll, getDownloadURL } from '../connection.js'; // Firebase Storage
import axios from 'axios'; // Para realizar la descarga de archivos    

try {
        const storagePath = `${companyName}/${agencyName}`;
        const listRef = ref(storage, storagePath); // Referencia a la carpeta en Firebase
        console.log(`Listando archivos en: ${storagePath}`);

        const res = await listAll(listRef);

        for (const itemRef of res.items) {
            const fileName = itemRef.name;
            try {
                const downloadUrl = await getDownloadURL(itemRef); // Obtener la URL de descarga
                console.log(`URL de descarga para ${fileName}: ${downloadUrl}`);

                const localFilePath = path.join(mediaPath, fileName);
                const writer = fs.createWriteStream(localFilePath);
                const response = await axios({
                    url: downloadUrl,
                    method: 'GET',
                    responseType: 'stream'
                });

                response.data.pipe(writer);

                // Esperar hasta que el archivo esté completamente descargado
                await new Promise((resolve, reject) => {
                    writer.on('finish', resolve);
                    writer.on('error', reject);
                });

                console.log(`Archivo descargado: ${localFilePath}`);
            } catch (downloadError) {
                console.error(`Error al obtener la URL de descarga para ${fileName}:`, downloadError);
            }
        }

        console.log('Descarga completa');
    } catch (error) {
        console.error('Error al buscar y descargar videos:', error);
    }
};

I review my storage in firebase and all the folders exists, i review all the docs i found but none of them shows me like a real solution, I’d used chat GPT for any other answer to that problem but none of the possible solutions worked for me 🙁