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

321
Views
open a file as base 64 in nodejs

quick question here, I'm pretty confident this is not complicated and a lot of chance that is a duplicate but I still cannot find a way to do it.

I'm in the backend and the front end return send me a cdv file in the body. I cannot change that.

What I need to do is simply parse it but this is the trick. I can't "open" the given data to have something to work with cdv-parse.

the format of the data is (when I do a console.log): data:text/csv;name=toto.csv;base64,VHlwZSBk (and so on)

 console.log(myfile);  // data:text/csv;name=toto.csv;base64,VHlwZSBk (and so on)
 console.log(fs.readFileSync(myfile, "base64"), "base64")); // error: ENOENT: no such file or directory, open 'u�Z��m�

I also tried with ```Buffer.from(myfile, "base64").toString()`` and again the format isn't the data expected.

EDIT: it seem that using myfile = myfile.replace("data:text/csv;name=toto.csv;base64,", "");does the trick with buffer.from().toString();

but I want something more générique, I guess something exist no ?

Thanks in advance

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!