Move the upload handling stuff to a separate module