问题
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:
- Yes
- No
- No
- No
- 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