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

270
Vistas
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 Respuestas
Responde la pregunta

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