How to use the “KeepRevisionForever” property to keep all file versions

强颜欢笑 提交于 2021-01-28 04:41:18

问题


I've recently loaded documents into Drive in C#, but was not aware of the KeepRevisionForever property. Now that I'm trying to upload newer versions of the documents, I'm trying to set this property to true, but it looks like it will only keep this property for the latest update. I.e., I'll upload up to version 5, but the KeepRevisionForever property is only set for version 4, not versions 1 - 3. Can the API allow for keeping revisions for all updates?

Below is the code block where this is being done:

Google.Apis.Drive.v3.Data.File fileUpdate = new Google.Apis.Drive.v3.Data.File
{
    Name = doc.Name + "." + doc.ApplicationExtension
    , ModifiedTime = doc.DateModified.ToUniversalTime()
};

var update = aobjservice.Files.Update(fileUpdate, doc.GoogleObjectId, docUploadStream, doc.mimetype);
update.KeepRevisionForever = true;
update.Fields = "*";

var task = update.Upload();

UPDATE: I'm up to 34 previous versions of this file, plus the current version (35), and I'm noticing that the older ones get this property checked. And if I keep updating this file, it'll keep updating this property for the file that's 3 versions prior to the current. Below are the version numbers and whether the "Keep revision forever" is checked for that version:

  1. Yes
  2. No
  3. No
  4. No
  5. Yes

回答1:


According to Manage Revisions, just set the keepRevisionForever to true if you don't want Drive API to auto-purge old revisions:

Google Drive automatically purges (or "prunes") older revisions in order to optimize disk usage. To prevent this from happening, you can set the boolean flag keepRevisionForever to true to mark revisions that you don't want Drive to purge.



来源:https://stackoverflow.com/questions/50930965/how-to-use-the-keeprevisionforever-property-to-keep-all-file-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!