Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

252
Vistas
How to convert a javascript object into a Blob and back again?

I have an object containing a nested array of objects, each containing buffers of jpeg images :-

   const imageBufferObject1 = { id: "123456-001", buffer: "...Uint8Array" };
   const imageBufferObject2 = { id: "123456-002", buffer: "...Uint8Array" };

const mediaObject = {
        id: "123456",
        mediaBufferArray: [
          imageBufferObject1,
          imageBufferObject2,
          ...
          imageBufferObject200,
        ],
      };


I've successfully converted the Object into a Blob to store in a database:

const mediaObjectBlob = new Blob([JSON.stringify(mediaObject)])

... and saved it as a Blob.

On retrieving it from the database, I get the following on the client side:


fetchedBlob:


Blob {size: 1249513, 
      type: 'application/octet-stream'}
      size: 1249513
      type: "application/octet-stream"[[Prototype]]: Blob
      arrayBuffer: ƒ arrayBuffer()
      size: (...)
      slice: ƒ slice()
      stream: ƒ stream()
      text: ƒ text()
      type: (...)
      constructor: ƒ Blob()
      Symbol(Symbol.toStringTag): "Blob"get size: ƒ size()
       get type: ƒ type()[[Prototype]]: Object

I'm trying to extract the original JS Object from the Blob using the following:

const retrievedObject = JSON.parse(fetchedBlob)

but only getting the following back when I console.log:

Blob {size: 1249513, type: 'application/octet-stream'}

Question: How do I extract the original JS Object so that I can access the mediBufferArray ?

Please help.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda