0

i'm using Next JS 13 and firebase@latest. i've created a drop zone and it accepts an array of images. so now i want to store this array of images in firebase storage and store the url's inside firestore.

this is how i'm pushing to firestore

import { db } from "../../firebase";
import { collection, doc, addDoc } from "firebase/firestore/lite";
import { useSession } from "next-auth/react";

export default function Home(

  const { data: session } = useSession();

  const createDocument = () => {
    const docRef = doc(db, "allPosts", session?.user?.email);
    const colRef = collection(docRef, "posts")
    addDoc(colRef, {
      name: name,
      desc: desc,
      images: images
    });
  };
)

so how can i push the images to firebase storage and then store the url's of those array of images inside my firestore? ie: the images doc is just to show where the url's go.

the image array

[
  {
    id: 1
    name: "image_processing20220628-4591-yzir35.png"
    src: "blob:http://localhost:3000/6e2f33e5-a749-4e9a-b502-d20b8e3f38ca"
  }
 ...
]
Mohammed Bekele
  • 727
  • 1
  • 9
  • 25

0 Answers0