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

請注意,目前如果使用者擁有約一百萬個檔案,系統會忽略要求的排序順序。

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 表示法
{
  "items": [
    {
      object (File)
    }
  ],
  "nextPageToken": string,
  "kind": string,
  "etag": string,
  "selfLink": string,
  "incompleteSearch": boolean,
  "nextLink": string
}
欄位
items[]

object (File)

檔案清單。如果已填入 nextPageToken,則這個清單可能不完整,應擷取其他結果頁面。

nextPageToken

string

下一頁檔案的頁面符記。如果已到達檔案清單結尾,則不會顯示這個按鈕。如果系統基於任何原因拒絕符記,就應捨棄該符記,並從第一頁結果重新開始分頁。

kind

string

這個值一律為 drive#fileList

etag

string

清單的 ETag。

授權範圍

需要下列其中一種 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 與使用者網域共用的項目。