Moved API upload logic to IO.php so that upload and download logic are bundled together in one location. Part of #933