Issue #2863127: moves file saving logic into a single place so that we have consistent behavior when saving provider files or regular files.