Extracted all file upload logic into separate file