Google Drive 文档时间戳 [英] Google Drive Document Time Stamp

查看:27
本文介绍了Google Drive 文档时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我假设 modifiedDate 搜索字段是修改(显然)或上传到驱动器的日期.有没有办法在其本机系统上保留文件的原始创建日期?或者有没有可能修改这个字段?谢谢你,肖恩

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

推荐答案

上传后可以使用File.Update设置修改日期.

You can use File.Update to set the modification date after upload.

https://developers.google.com/drive/v2/reference/文件/更新

此外,File.Patch 也可以:

Also, File.Patch works too:

https://developers.google.com/drive/v2/reference/文件/补丁

我知道我在某个时候阅读了另一个旧线程,其中讨论了能够在插入时保留原始创建日期,或者至少将其作为一个选项,但此功能尚不存在.(现在找不到帖子了……)

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...)

更新:

我认为有一个更新文档时间戳的方法会很好,所以这里是:

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 文档时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆