file upload refactoring