Merged do_upload functions back into one