refactor upload.