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

225
Visualizações
How to know file type in file object when type propery is empty

I'm reading a file in android application with:

<ion-input type="file" (change)="readFile($event)"></ion-input>

I get a file object, and I can know the file type by checking the type property.

But some files have empty type property, as you can see in the following screenshot:

enter image description here

How can I konw the file type if it has empty type property and no extension?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I had this problem a while ago, when using a Windows machine.
Fixed the issue following this answer.

To quote: "As i was expecting, issue is system specific where content-type for .csv type is missing under Registry (HKEY_CLASSES_ROOT.csv)."

about 4 years ago · Juan Pablo Isaza Relatório

0

A solution that I find is to convert it to base64, for example with this code:

getBase64(file)
  {
    return new Promise((resolve, reject) =>
    {
      const reader = this.getFileReader();// this function is important for real devices. Without it the fielReader.onload will not be triggered in read device
      reader.readAsDataURL(file);
      reader.onload = () => resolve(reader.result);
      reader.onerror = error => reject(error);
    });
  }

the return will look like that:

'data:application/octet-stream;base64,T2dnUwACAAAAAAAAAAAAAAAAAAAAACqCBoIBE09wdXNIZWFkAQFoAIA+AAAAAABPZ2dTAAAAAAAAAAA ...

As you can see, after data: we get the type. In this case application/octet-stream

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