I assume that the modifiedDate search field is the date of modification (obviously) or upload to the drive. Is there a way to preserve the original creation date of the file on its native system? Or is there a possibility to modify this field? Thank you, Sean
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can use File.Update to set the modification date after upload.
https://developers.google.com/drive/v2/reference/files/update
Also, File.Patch works too:
https://developers.google.com/drive/v2/reference/files/patch
I know that I read another old thread sometime where it was discussed that it would be nice to be able to preserve the original creation date on insert, or at least to have that as an option, but this functionality does not exist yet. (Can't find the post now...)
UPDATE:
I decided it would be nice to have a method to update the document time stamp, so here it is:
public static File SetLastModified(string fileID, DateTime lastModified)
{
File file = DriveService.Files.Get(fileID).Fetch();
file.ModifiedDate = lastModified.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.fff'Z'");
try
{
FilesResource.UpdateRequest request = DriveService.Files.Update(file, fileID);
request.SetModifiedDate = true;
file = request.Fetch();
}
catch (Exception e)
{
throw;
}
return file;
}
标签:
google-drive-sdk