Refactored the upload API