Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created Jan 28, 2021
Embed
What would you like to do?
const EXTENSIONES_ICONOS = {
"txt": "file-document-outline",
"pdf": "file-pdf-box",
"sql": "database",
"exe": "microsoft-windows",
"jpg": "image",
"png": "image",
"go": "language-go",
"py": "language-python",
"c": "language-c",
"cpp": "language-cpp",
"cs": "language-csharp",
"java": "language-java",
"js": "language-javascript",
"mkv": "movie",
"mp4": "movie",
"avi": "movie",
"msi": "microsoft-windows",
"zip": "zip-box",
"rar": "zip-box",
};
const ICONO_POR_DEFECTO = "file";
const Utiles = {
obtenerExtensionDeArchivo(nombreArchivo) {
if (!nombreArchivo) {
return "";
}
return nombreArchivo.substring(nombreArchivo.lastIndexOf(".") + 1);
},
obtenerIconoSegunNombreArchivo(nombreArchivo) {
return EXTENSIONES_ICONOS[Utiles.obtenerExtensionDeArchivo(nombreArchivo)] || ICONO_POR_DEFECTO;
}
};
export default Utiles;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment