Next.js Discord

Discord Forum

Handling images on next/server

Unanswered
Netherland Dwarf posted this in #help-forum
Open in Discord
Avatar
Netherland DwarfOP
const imageBlob = await imageResponse.blob();

  console.log(imageBlob);

  const imageURL = URL.createObjectURL(imageBlob);

  console.log(imageURL);

  const storage = getStorage();
  const storageRef = ref(storage, `journal/${userId}.png`);
  await uploadBytes(storageRef, imageBlob);

  // // get the download url
  const downloadURL = await getDownloadURL(storageRef);

  return NextResponse.json({ imageURL, downloadURL }, { status: 200 });


can anyone help me with this - this uploadBytes fn from firebase isnt able to get the blob and shows - TypeError: Cannot read properties of undefined (reading 'byteLength')

6 Replies

Avatar
Netherland DwarfOP
can i not use firebase/storage inside /api
Avatar
Netherland DwarfOP
error consoled

error TypeError: Cannot read properties of undefined (reading 'byteLength')
    at eval (webpack-internal:///(rsc)/./node_modules/@firebase/storage/dist/node-esm/index.node.esm.js:1182:38)
    at Array.forEach (<anonymous>)
    at FbsBlob.getBlob (webpack-internal:///(rsc)/./node_modules/@firebase/storage/dist/node-esm/index.node.esm.js:1181:25)
    at multipartUpload (webpack-internal:///(rsc)/./node_modules/@firebase/storage/dist/node-esm/index.node.esm.js:1706:26)
    at uploadBytes$1 (webpack-internal:///(rsc)/./node_modules/@firebase/storage/dist/node-esm/index.node.esm.js:2762:25)
    at uploadBytes (webpack-internal:///(rsc)/./node_modules/@firebase/storage/dist/node-esm/index.node.esm.js:3209:12)
    at POST (webpack-internal:///(rsc)/./app/api/journal/route.ts:83:72)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async eval (webpack-internal:///(rsc)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:253:37)
Avatar
Netherland DwarfOP
Image
Image
how do i handle responses that are images in using fetch
Avatar
Netherland DwarfOP
???
🥹