Refactor file upload support.