如何使用 "KeepRevisionForever" 属性 保留所有文件版本
How to use the "KeepRevisionForever" property to keep all file versions
我最近用 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:
- Yes
- No
- No
- No
- 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# 将文档加载到 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:
- Yes
- No
- No
- No
- 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.