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

269
Views
What is Object Buffer in Node?

In nodejs, I have:

  const fileToUpload = fs.readFileSync(test_file_path);
  console.log("fileToUpload: type: ", typeof fileToUpload, ", content: ", fileToUpload);

which prints:

type: object,  content:  <Buffer 50 4b 03 04 14 00 08 00 08 00 78 84 cb 50 00 00 00 00 00 00 00 00 24 ae 12 01 3e 00 20 00 31 2e 32 2e 38 34 30 2e 31 31 33 35 36 34 2e 31 30 2e 31 2e ... 10573784 more bytes>

I get that the type of fileToUpload is object. This is basic javascript type. But what is <Buffer 50 4b 03 04 ....>? Is it binary format?

In frontend built with ReactJS, how can I convert an attached zip file to this <Buffer ... > type?

The reason I'm asking is that I need to get a file in such format in reactjs client side to be able to upload it to AWS s3 bucket. More details on: Javascript on client side: how to upload a zip file to AWS S3 bucket through pre-signed URL?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

See Node.js docs:
https://nodejs.org/api/fs.html#fsreadfilesyncpath-options

If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.

So, to get a string you can write e.g.:

const text = fs.readFileSync(filePath, 'utf8');

The Buffer class is a subclass of JavaScript's Uint8Array.

The Buffer (Uint8Array) has some converter methods as well:

  • https://nodejs.org/api/buffer.html#buffer
about 4 years ago · Juan Pablo Isaza Report
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!