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

326
Visualizações
How to read exact mimetype of a file ? file-type npm package decides it on extension

I am trying to get filetype(MIMETYPE) of a JS file at both client and server end.

at client end I am using file-type npm package and reading the mimetype. But I found that if I change the extension of Javascript file(test.js) as docx (text.docx) file-type npm package fails to read exact type and consider the file as .docx

client side code:

import * as fileTypeForMimeType from 'file-type';
...
...
const fileData = await fileTypeForMimeType.fromBuffer(bytes);
realFileType = fileData ? fileData.mime : file.type;

screen shot of client side where it is reading the file as .docx screen shot of client side

What is right way to read files exact mime-type ? if Yes. how ?

any other packages give more accurate results ?

and finally how to get most accurate file-type at server end ? (nodejs, loopback)

Thanks

about 4 years ago · Juan Pablo Isaza
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