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

626
Views
Enviar ArrayBuffer al servidor NodeJS Express

Quiero cargar un archivo grande en mi servidor localhost. Y debido a que el tamaño del archivo será grande (tal vez 500 MB), necesito enviar los datos chunk by chunk desde el cliente. Luego, mi servidor Nodejs seguirá agregando los datos a un temp file . Finalmente, cambiaré el formato del archivo y lo guardaré.

El problema es que no sé cómo enviar y leer datos correctamente. Así es como lo estoy haciendo ahora, en mi servidor sigo obteniendo el objeto {} .

Lado del cliente:

 // 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

Configuración de mi aplicación:

 /* 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))

mi ruta

 fileUploadRouter.post('/', async ( req, res, next ) => { var buffer = req.body console.log(buffer) })

¡Gracias por tu ayuda!

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!