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

265
Views
How to convert reponse stream to blob on javascript client side?

I am unable to create a blob from the response stream of a request (the response comes from a node js server), here is the code:

fetch('/api/load', {
  method: 'POST',
  headers: { 'Content-Type': 'text/plain' },
  body: src

}).then((response) => {
  const reader = response.body.getReader()

  return new ReadableStream({
    start(controller) {
      return pump()

      function pump() {
        return reader.read().then(({ done, value }) => {
          if (done) {
            controller.close();
            return;
          }
          controller.enqueue(value);
          return pump();
        })
      }
    }
  })

}).then((stream) => {
  // What to do next with the stream???
})

I already tried new Blob([new Uint8Array(stream)], {type: 'image/jpeg'}), but it doesn't work :(

What is the correct way to create a blob from the stream?

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!