昨天下午,我开始遇到问题,我的Google云端硬盘应用无法再更新Google文档。我仍然可以更新其他文件类型,例如docx或rtf。这也发生在这里的同事身上,但是两个不同的用户仍然可以使用google drive应用程序并更新google文档而没有问题,而且我们都使用相同的版本。
我登录的是一个有效的Google帐户,而不是我自己的帐户,但无法更新该同事可以使用的同一Google文档。但是,与我有相同问题的同事登录了一个不同的Google帐户,并且他能够使用与以前相同的版本来更新Google文档。
突然之间这里发生了什么鬼事?两天前这对我们来说都是有效的。
这是我请求权限的地方:
GoogleWebAuthorizationBroker.Folder = "Tasks.Auth.Store";
StoredCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { DriveService.Scope.Drive,
DriveService.Scope.DriveFile },
"user",
CancellationToken.None,
new SavedDataStore()).Result;
我知道要进入的文件ID:
request = service.Files.Get(fileID);
myFile = request.Execute();
使用Google文档时,我将其下载为docx文件,因此:
if (myFile.MimeType == "application/vnd.google-apps.document")
myFile.MimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
这是更新发生的地方:
try
{
//fileLoc contains the updated contents
byte[] byteArray = System.IO.File.ReadAllBytes(fileLoc);
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
FilesResource.UpdateMediaUpload updateRequest = service.Files.Update(myFile, fileID, stream, myFile.MimeType);
//fileID is used to get myFile in the first place; myFile is = to myFile.Id
updateRequest.Upload();
}
catch (Exception e)
{
MessageBox.Show("An error occurred: " + e.Message);
}
发生此请求时不会引发任何错误,甚至会更新这些文件上的时间戳,但内容不会更新。我正在迷失方向试图解决这个问题,我不知道出了什么问题,也不知道从哪里开始寻找。
出现了暂时的故障,现在应该再次运行。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句