uploadFile throws an exception if the API returned an error