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

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

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 Denunciar

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