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

下一頁檔案的網頁權杖。如果已達檔案清單的結尾,則不會顯示這個 ID。如果權杖因任何原因遭拒,則應捨棄權杖,且應從結果的第一頁重新開始分頁。

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