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

261
Vistas
How to get file extension from file content using Node.js

I need some help. I need to fetch what the file type should be from the file containing only using Node.js. I am explaining the scenario below.

Let's say I have some content like below.

let fileContent = "The textContent property sets or returns the text content of the specified node, and all its descendants."

As we can see here the variable fileContent has some text data and I want to write this data into one file. So for that, I need to create the file with a proper extension like abc.txt. Similarly, If fileContent has some json data then I will create the file like abc.json and write the value inside it.

So here I need to fetch what should be the type of file from this content only using Node.js. If anybody has a solution for this will be a great help.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use popular file-type package for this. You can send buffer/file/stream/blob as an input and get file type as an output.

const FileType = require('file-type');
...
const { ext, mime } = await FileType.fromBuffer(your_data);
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