Small refactoring of upload server side code