Refactored and optimized code for mass uploading from local path