[ADD] use libmagic or mimetypes to detect a file's type