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

以半形逗號分隔的標籤 ID 清單,用於納入回應的 labelInfo 部分。

要求主體

要求主體必須為空白。

回應主體

檔案清單。

如果成功,回應主體會含有以下結構的資料:

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 共用至使用者網域的項目。