Method: files.list

列出使用者的檔案。

這個方法接受 q 參數,這是結合一或多個搜尋字詞的搜尋查詢。詳情請參閱搜尋檔案並資料夾指南。

HTTP 要求

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

這個網址使用 gRPC 轉碼語法。

查詢參數

參數
corpora

string

查詢所適用的項目 (檔案/文件) 的主體。支援的主體包括 defaultdomaindriveallDrives。比較偏好 defaultdriveallDrives,藉此提高效率。

corpus
(deprecated)

enum (Corpus)

已淘汰:查詢所適用的項目 (檔案/文件) 主體。請改用 corpora

driveId

string

要搜尋的共用雲端硬碟 ID。

includeItemsFromAllDrives

boolean

是否同時包含「我的雲端硬碟」和共用雲端硬碟項目。

includeTeamDriveItems
(deprecated)

boolean

已淘汰:請改用 includeItemsFromAllDrives

maxResults

integer

每頁傳回的檔案數量上限。即使在檔案清單結尾前,部分或空白的結果頁面仍然可能出現。

orderBy

string

以逗號分隔的排序索引鍵清單。有效索引鍵為 createdDatefolderlastViewedByMeDatemodifiedByMeDatemodifiedDatequotaBytesUsedrecencysharedWithMeDatestarredtitletitle_natural。根據預設,每個索引鍵都會遞增排序,但可以使用 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 與使用者網域共用的項目。