Upload script refactoring