Method: files.list

列出用户的文件。

此方法接受 q 参数,该参数是包含一个或多个搜索字词的搜索查询。如需了解详情,请参阅搜索文件和文件夹指南。

HTTP 请求

GET https://www.googleapis.com/drive/v2/files

网址采用 gRPC 转码语法。

查询参数

参数
corpora

string

要查询的项(文件/文档)的正文。支持的正文为 defaultdomaindriveallDrives。为了提高效率,请优先使用 defaultdrive,而不是 allDrives

corpus
(deprecated)

enum (Corpus)

已废弃:要查询的项(文件/文档)的正文。请改用 corpora

driveId

string

要搜索的共享云端硬盘的 ID。

includeItemsFromAllDrives

boolean

结果中是否应同时包含“我的云端硬盘”和共享云端硬盘中的内容。

includeTeamDriveItems
(deprecated)

boolean

已弃用:请改用 includeItemsFromAllDrives

maxResults

integer

每页返回的最大文件数。即使未到达文件列表的末尾,也可能会出现部分或空白的结果页面。

orderBy

string

排序键的英文逗号分隔列表。有效键包括:

  • createdDate:文件的创建时间。
  • folder:文件夹 ID。此字段会按字母顺序排序。
  • lastViewedByMeDate:用户上次查看文件的时间。
  • modifiedByMeDate:用户上次修改文件的时间。
  • modifiedDate:文件上次被任何人修改的时间。
  • quotaBytesUsed:文件使用的存储空间配额字节数。
  • recency:文件日期时间字段中的最新时间戳。
  • sharedWithMeDate:与用户共享文件的时间(如果适用)。
  • starred:用户是否为文件添加了星标。
  • title:文件的标题。此字段会按字母顺序排序,即 1、12、2、22。
  • title_natural:文件的标题。此字段使用自然排序顺序进行排序,即 1、2、12、22。

每个键默认按升序排序,但可以使用“desc”修饰符进行降序排序。用法示例:?orderBy=folder,modifiedDate desc,title

请注意,目前,如果用户有大约 100 万个文件,系统会忽略所请求的排序方式。

pageToken

string

文件的页面令牌。

projection
(deprecated)

enum (Projection)

已废弃:此参数没有任何用途。

q

string

用于搜索文件的查询字符串。

spaces

string

要查询的聊天室的英文逗号分隔列表。支持的值包括 driveappDataFolder

supportsAllDrives

boolean

请求访问权限的应用是否同时支持“我的云端硬盘”和共享云端硬盘。

supportsTeamDrives
(deprecated)

boolean

已弃用:请改用 supportsAllDrives

teamDriveId
(deprecated)

string

已弃用:请改用 driveId

includePermissionsForView

string

指定要在响应中包含哪些其他视图的权限。仅支持 published

includeLabels

string

要包含在响应的 labelInfo 部分中的标签 ID 的逗号分隔列表。

请求正文

请求正文必须为空。

响应正文

文件列表。

如果成功,响应正文将包含结构如下的数据:

JSON 表示法
{
  "nextPageToken": string,
  "kind": string,
  "etag": string,
  "selfLink": string,
  "incompleteSearch": boolean,
  "nextLink": string,
  "items": [
    {
      object (File)
    }
  ]
}
字段
nextPageToken

string

下一页文件的页面令牌。如果已到达文件列表的末尾,则此字段将不存在。如果令牌因任何原因被拒绝,则应将其舍弃,并从第一页结果开始重新分页。

kind

string

此值始终为 drive#fileList

etag

string

列表的 ETag。

items[]

object (File)

文件列表。如果已填充 nextPageToken,则此列表可能不完整,并且应提取下一页的结果。

授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/docs
  • https://www.googleapis.com/auth/drive
  • https://www.googleapis.com/auth/drive.appdata
  • https://www.googleapis.com/auth/drive.apps.readonly
  • https://www.googleapis.com/auth/drive.file
  • https://www.googleapis.com/auth/drive.meet.readonly
  • https://www.googleapis.com/auth/drive.metadata
  • https://www.googleapis.com/auth/drive.metadata.readonly
  • https://www.googleapis.com/auth/drive.photos.readonly
  • https://www.googleapis.com/auth/drive.readonly

某些镜重受限,您的应用需要接受安全评估才能使用它们。如需了解详情,请参阅授权指南

语料库

枚举
DEFAULT 用户访问过的内容。
DOMAIN 共享到用户网域的内容。