Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

267
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda