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

628
Views
Send ArrayBuffer To NodeJS Express Server

I'm want to upload big file to my localhost server. And because the file size will be big ( 500MB maybe ), so I need to send the data chunk by chunk from client. Then my Nodejs server will keep appending the data to a temp file. Finally, I will change the file format and save it.

The problem is, I don't know how to send & read data properly. This is how I'm doing now, in my server I keep getting {} object.

Client Side:

// Prepare & Start Upload
      const reader = new FileReader();
      reader.addEventListener("load", async () => {

        await fetch('/api/v1/file/upload/',  {
          method: 'POST',
          body:  reader.result
        });
      })

      reader.readAsArrayBuffer( file.slice(0) ); // try to read whole file(small) first

My app setup:

/* Register Middlewares */
  app.use(express.json())
  app.use(express.urlencoded({extended:true}))
  app.use('/api/v1/file/upload', fileUploadRouter)
  app.use(express.static('./views'))
  app.use(appError)

  /* App Start */
  const PORT = process.env.PORT || 3000
  app.listen(PORT, () => console.log('Listening to: localhost:'+PORT))

My route

fileUploadRouter.post('/', async ( req, res, next ) => {

  
  var buffer = req.body

  console.log(buffer)
})

Thank for your 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!