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 部分加入的標籤。

要求主體

要求主體必須為空白。

回應主體

檔案清單。

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

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