Google云端硬盘文档时间戳 [英] Google Drive Document Time Stamp
问题描述
我假设 modifiedDate 搜索字段是修改(显然)或上传到驱动器的日期。有没有办法在原生系统上保留文件的原始创建日期?或者是否有可能修改此字段?
谢谢,Sean
您可以使用File.Update设置上传后的修改日期。
https://developers.google .com / drive / v2 / reference / files / update
另外,File.Patch也可以运行:
https://developers.google.com/drive/v2/reference / files / patch
我知道我在某个时候读过另一个旧线程,在那里讨论过能够保留原始创建日期在插入,或至少有作为一个选项,但这个功能尚不存在。 (现在找不到帖子...)
更新:
我决定这会很好有一个方法来更新文档时间戳,所以这里是:
pre $ 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');
尝试
{
FilesResource.UpdateRequest request = DriveService.Files.Update(file,fileID);
request.SetModifiedDate = true;
file = request.Fetch();
}
catch(异常e)
{
throw;
}
返回文件;
}
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
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云端硬盘文档时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!