gpt4 book ai didi

c# - 如何使用 "KeepRevisionForever"属性保留所有文件版本

转载 作者:太空宇宙 更新时间:2023-11-03 12:13:25 24 4
gpt4 key购买 nike

我最近用 C# 将文档加载到 Drive 中,但不知道 KeepRevisionForever 属性。现在我正在尝试上传更新版本的文档,我正在尝试将此属性设置为 true,但看起来它只会为最新更新保留此属性。即,我将上传至版本 5,但 KeepRevisionForever 属性仅针对版本 4 而不是版本 1 - 3 设置。API 是否允许保留所有更新的修订?

下面是执行此操作的代码块:

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

最佳答案

根据 Manage Revisions ,如果您不希望 Drive API 自动清除旧修订,只需将 keepRevisionForever 设置为 true:

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.

关于c# - 如何使用 "KeepRevisionForever"属性保留所有文件版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50930965/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com