For a sake of code reuse you could make use of https://github.com/spawngrid/mimetypes Cheers, Gleb Peregud