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

198
Vistas
Convert uploaded PDF to file in node

I'm working on a codebase and I have to extend a controller to allow uploading of PDF files. I'm submitting the file through jquery/ajax with formData.

The Backend contains of a pretty large framework, which has its own type of request - So using something like formidable is out of the question for handling the file upload server side.

My Problem: The POST request arrives on the server and when I log the body parameter that contains the file I get the following:

file: [
 37,  80,  68,  70,  45,  49,  46,  51,  10,  37, 255, 255,
255, 255,  10,  56,  32,  48,  32, 111,  98, 106,  10,  60,
 60,  10,  47,  84, 121, 112, 101,  32,  47,  69, 120, 116,
 71,  83, 116,  97, 116, 101,  10,  47,  67,  65,  32,  49,
 10,  62,  62,  10, 101, 110, 100, 111,  98, 106,  10,  55,
 32,  48,  32, 111,  98, 106,  10,  60,  60,  10,  47,  84,
121, 112, 101,  32,  47,  80,  97, 103, 101,  10,  47,  80,
 97, 114, 101, 110, 116,  32,  49,  32,  48,  32,  82,  10,
 47,  77, 101, 100,
... 23741 more items

]

Which, from my understanding is an Array Buffer of the uploaded file. Now I've read that I can just write this to the file system with the fs library like this:

fs.writeFile(filename, data);

Which does create the file on the server, however it is always a corrupted file and not an actual pdf.

What am I missing, I'm assuming it has something to do with the encoding of the formData that I'm not aware of?

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