escape spaces in filenames and include authority_id in filenames for agents when present