Refactored CMS file upload