[Refactor] Upload: Move upload logic into lib module