implement _put_file func used by _save func