upload_file: minor refactoring