const { readFileSync } = require("node:fs");
const firebase = require("../firebase");
const {
getStorage,
ref,
uploadBytes,
getDownloadURL,
} = require("firebase/storage");
const storage = getStorage();
let image = ""
// Create a reference to 'mountains.jpg'
const storageRef = await ref(storage, "images/" + req.file.filename);
await uploadBytes(storageRef, readFileSync(req.file.path)).then(
async (snapshot) => {
await getDownloadURL(snapshot.ref).then((downloadURL) => {
console.log(downloadURL.toString());
image = downloadURL.toString();
});
}
);
return image;