Moved file upload code to utils