The undertaking must be filed by the magistrate in the office of the clerk of the district court.