【问题标题】:Is there a way to list all fields for a file on the Google Drive API?有没有办法在 Google Drive API 上列出文件的所有字段?
【发布时间】:2021-03-22 06:21:14
【问题描述】:

我有一个简单的问题。当我请求root as parent or sharedWithMe = true 时,我得到的文件夹比我分别请求root as parentsharedWithMe = true 时少。我还没有找到显示在单个查询中但未能显示在组合查询中的文件夹之间的区别。

我的希望是,如果我查询所有字段,那么也许我就能分辨出区别。有没有办法做到这一点?或者是否有 Google Drive API 的游乐场,我可以在其中测试不同的查询?

这是返回少于应有的文件夹的代码:

val response =
 gDriveClient.files()
 .list()
 .setSpaces("drive")
 .setCorpora("user")
 .setFields("files(id, name, size, modifiedTime, mimeType, parents, quotaBytesUsed),nextPageToken")
 .setQ("('root' in parents or sharedWithMe = true) and trashed = false")
 .setSupportsAllDrivers(true)

如果我运行.setQ("('root' in parents) and trashed = false").setQ("(sharedWithMe = true) and trashed = false"),那么我得到的结果比上面的代码更多。一些共享文件夹是我缺少的。

谢谢。

编辑:只是想澄清一下,下面的正确答案是 * 获取所有字段。我的实际问题的答案是我没有设置pageSize,默认情况下限制为100。

【问题讨论】:

标签: google-api google-drive-api google-drive-android-api


【解决方案1】:

返回所有字段设置字段等于*

.setFields("*")

至于您的问题,对我来说这听起来像是一个错误,您可能要考虑提交报告听起来像一个错误,我会将其提交给issue forum

【讨论】:

  • 不敢相信我没想到要放 *。在提交错误之前我会尝试更多的东西,谢谢。
  • 我不敢相信 v3 默认只返回所有内容,但强制使用字段。 ?
  • * 确实为我工作,不确定它让我得到了一切,但它得到了很多东西。原来问题是页面大小。
猜你喜欢
  • 2014-02-05
  • 1970-01-01
  • 2022-01-05
  • 1970-01-01
  • 2021-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-31
相关资源
最近更新 更多