This should absolutely be in its own file. If this works well, we'll use it in other places, since uploading is order of magnitude slower than downloading, esp. in poor connectivity places.