Google云端硬盘文档时间戳 [英] Google Drive Document Time Stamp

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

问题描述

我假设 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屋!

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