Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!