A clearer way to do this would be to put a new begin / ensure inside the if above (and just wrap the actual upload)