【问题标题】:add file property (like jQuery's .data()) to a GDrive file - Google App Script将文件属性(如 jQuery 的 .data())添加到 GDrive 文件 - Google App Script
【发布时间】:2014-11-13 16:11:37
【问题描述】:

我想知道是否有一种方法可以使用 Google App Script 将某种信息附加到 GDrive 文件中。例如,我目前正在使用 GAS 制作一些 google 电子表格,我确实需要在这些电子表格中附加一些有用的信息,例如“已经看过”或“已经处理”。

我一直在寻找类似jQuery's .data() 的东西,但到目前为止我还没有找到任何东西。

var ss = SpreadsheetApp.openById(spreadsheetId);
ss.data("processed", "true").data("seen", "false")  //--- something like this

有人知道这是否可能吗?有什么解决方法或技巧可以做到这一点?

谢谢

【问题讨论】:

    标签: google-apps-script google-sheets file-properties


    【解决方案1】:

    听起来你可能感兴趣的是Drives custom file properties. 你可以找到更多关于方法here。我对编程很陌生,而且我从未使用过这个特殊功能,但我相信它可以让您为 Drive 文件指定自定义属性。

    【讨论】:

    • 我不相信这是可能的。我相信我上面概述的方法是唯一的方法。
    【解决方案2】:

    目前,这不可能如您所愿。目前只有一种方法可以使用 Google Drive Web API 设置自定义属性。

    【讨论】:

      【解决方案3】:

      我找到的唯一解决方案(也许将来有可能将数据添加到 GDrive 文件),使用 GAS,使用文件描述来获取/设置附加信息..

      // Gets the first document's description.
      // Note: This can also be used on a folder
      var doc = DocsList.getFilesByType(DocsList.FileType.DOCUMENT)[0];
      Logger.log(doc.getDescription());
      
      // This example sets the first document's description
      // Note: This can also be used on a folder
      var doc = DocsList.getFilesByType(DocsList.FileType.DOCUMENT)[0];
      doc.setDescription('My First Doc');
      Logger.log(doc.getDescription()); // logs 'My First Doc'
      

      文档HERE

      我使用描述字段来存储我的所有信息,并用管道分隔。当我需要获取特定文件信息时,我会解析描述字符串以查找我需要的内容。基本上就像 cookie 一样工作。

      【讨论】:

        猜你喜欢
        • 2019-03-22
        • 2021-06-03
        • 2014-07-22
        • 2013-11-08
        • 2011-04-04
        • 2010-11-24
        • 1970-01-01
        • 2017-04-22
        • 1970-01-01
        相关资源
        最近更新 更多