如何使用 Google Drive API 搜索自定义文件属性?

Gra*_*yle 5 google-drive-api

Google Drive 允许您将自定义属性添加到文件 ( https://developers.google.com/drive/v3/web/properties ),但它们不包含在可搜索文本中。

https://developers.google.com/drive/v3/web/search-parameters

fullText string contains Full text of the file including name, description, content, and indexable text.

您只能搜索完全匹配的属性:

appProperties 有 { key='additionalID' and value='8e8aceg2af2ge72e78' }

还有其他方法可以搜索自定义属性吗?

示例:如果我有一个带有自定义属性“标签”和值“活动银行紧急”的文件,我如何才能files.listhttps://developers.google.com/drive/v3/reference/files/list)找到这个文件当我搜索“紧急”时?

Tan*_*ike 6

论文方法呢?不幸的是,它找不到appProperties使用q. 因此,为了实现您想要做的事情,我提出了以下 2 种模式。

模式一

  1. 检索具有 appPropertiesfiles/appProperties用作查询参数的文件列表。
    • GET https://www.googleapis.com/drive/v3/files?fields=files%2FappProperties
    • 只有appProperties从谷歌云端硬盘中的所有文件检索。
  2. 通过脚本检索您需要的关键“标签”和值“活动银行紧急”。
  3. 使用appProperties has { key='tags' and value='active banking urgent' }for检索文件q

在此模式中,API 的使用计数为 2。

模式2

  1. 检索具有 appPropertiesfiles(appProperties,id,name)用作查询参数的文件列表。
    • GET https://www.googleapis.com/drive/v3/files?fields=files(appProperties%2Cid%2Cname)
    • appPropertiesfileIdfilename从 Google Drive 上的所有文件中检索。这些参数被搜索为or
  2. 通过脚本,检索具有 属性的元素appProperties,并检索具有 appProperties(键“标签”,值“活动银行紧急”)的文件。

在此模式中,API 的使用计数为 1。

如果这对你没有用,我很抱歉。