Refactor upload functions into the upload model.