refactor upload:encode file with base64, detach upload from main loop