Extract mime-type detection into discrete module