当我上传或下载一个大文件并且持续时间超过一小时时,上传/下载会在一小时后中断并显示以下错误消息:
Google.GoogleApiException: Google.Apis.Requests.RequestError
Invalid Credentials [401]
Errors [
Message[Invalid Credentials] Location[Authorization - header] Reason[authError] Domain[global]
]
无论我使用 Web 授权还是服务帐户授权来运行它,都没有区别。
我不确定这是否与AuthToken过期有关,因为如果我上传较小的文件,那么我可以上传很多文件,并且一个小时后不会中断。对于小文件,一切都运行顺利并且可以工作很长时间。
看起来描述了类似的问题 here ,但这个问题尚未得到解答。
我的代码如下:
DriveService service;
// ....
FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, mimeType);
request.Upload();
最佳答案
问题出在 Google 云端硬盘端点上,无法在您的代码中修复。
有人提交了 an issue about this截至2013年1月13日,一年多过去了,谷歌似乎没有对此进行任何更新,而其他人仍然遇到这个问题。
This is an issue with the backend and not with the API or with your code. As you deduced, if the upload goes too long the access_token expires and at that point the resumable upload can't be continued. There is work on progress to fix this issue right now, I will update this bug once the issue is fixed on the server side.
这是another report关于这个问题。
关于google-api - Google Drive API 1.8.1 - 大文件上传/下载问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23696484/