Refactor upload method.