【问题标题】:How do I use the appProperties with the ruby api-client如何将 appProperties 与 ruby​​ api-client 一起使用
【发布时间】:2016-04-11 04:04:41
【问题描述】:

我无法确定如何添加或搜索自定义属性。

当我尝试搜索它们时,我所做的一切都是给我Error - #<Google::Apis::ClientError: invalid: Invalid query>。我可以成功完成其他查询,但我不知道客户端是否设置为使用 appProperties(甚至是属性)。

基本上我只需要正确的语法来搜索和添加,因为它似乎不在文档中。

【问题讨论】:

    标签: google-api-ruby-client


    【解决方案1】:

    假设您已经拥有对授权 DriveService 的引用,您可以使用 q 参数(记录在 here)基于 appProperties 进行搜索,如下所示:

    file_list = drive.list_files(
      q: "appProperties has { key='my_app_key' and value='my_val' }",
      fields: 'files(id, name, appProperties)',
      spaces: 'drive')
    

    如果您省略 fields 参数,则搜索仍然有效,但不会返回属性本身。

    更新 appProperties 绝对是晦涩难懂的,而且文档也不透明。您需要的是文件的 ID,以及作为要更新属性的容器的 File 值对象。像这样的:

    new_app_properties = { 'my_app_key' => 'my_val' }
    update_f = Google::Apis::DriveV3::File.new(app_properties: new_app_properties)
    drive.update_file(file_id, update_f)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-11
      • 2016-11-27
      • 1970-01-01
      • 1970-01-01
      • 2020-03-31
      • 2018-03-02
      • 1970-01-01
      相关资源
      最近更新 更多