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

194
Views
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
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!