Fix bad file descriptor error when access token expires during file upload

[Fixes #65600288, #64649764, #65516908]