Method: files.list

列出使用者的檔案。

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

HTTP 要求

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

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

查詢參數

參數
corpora

string

查詢所適用的項目 (檔案/文件) 的主體。支援的主體包括「user」、「domain」、「drive」和「allDrives」。以「使用者」或「開車」取代「allDrives」以提高效率。根據預設,語料庫會設為「user」,但可能會依據透過「q」參數設定的篩選器設定而改變。

corpus
(deprecated)

enum (Corpus)

已淘汰:要列出的檔案來源。請改用「corpora」。

driveId

string

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

includeItemsFromAllDrives

boolean

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

includeTeamDriveItems
(deprecated)

boolean

已淘汰:請改用 includeItemsFromAllDrives

orderBy

string

以半形逗號分隔的排序索引鍵清單。有效鍵為「createdTime」、「folder」、「modifiedByMeTime」、「modifiedTime」、「name」、「name_natural」、「quotaBytesUsed」、「recency」、「sharedWithMeTime」、「starred」和「viewedByMeTime」。根據預設,每個鍵都會遞增排序,但可使用「desc」修飾符反轉。使用範例:?orderBy=folder,modifiedTime desc,name。

pageSize

integer

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

pageToken

string

繼續先前在下一頁提出清單要求的權杖。此值應設為前一個回應的「nextPageToken」值。

q

string

用於篩選檔案結果的查詢。如要瞭解支援的語法,請參閱「搜尋檔案和資料夾」指南。

spaces

string

要在語料庫中查詢的空格清單 (以半形逗號分隔)。支援的值為「drive」和「appDataFolder」。

supportsAllDrives

boolean

要求的應用程式是否支援「我的雲端硬碟」和共用雲端硬碟。

supportsTeamDrives
(deprecated)

boolean

已淘汰:請改用 supportsAllDrives

teamDriveId
(deprecated)

string

已淘汰:請改用 driveId

includePermissionsForView

string

指定要在回應中加入哪些其他檢視表權限。僅支援「已發布」。

includeLabels

string

要加入回應 labelInfo 部分的標籤 ID 清單 (以半形逗號分隔)。

要求主體

要求主體必須為空白。

回應主體

檔案清單。

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

JSON 表示法
{
  "nextPageToken": string,
  "kind": string,
  "incompleteSearch": boolean,
  "files": [
    {
      object (File)
    }
  ]
}
欄位
nextPageToken

string

下一頁檔案的頁面憑證。如果檔案清單已到達結尾,就不會顯示這個資料。如果權杖因任何原因而遭拒,請予以捨棄,並在結果第一頁重新開始分頁。網頁權杖通常會在幾小時內有效。不過,如果您新增或移除項目,預期結果可能會不同。

kind

string

識別資源的種類。值:固定字串 "drive#fileList"

files[]

object (File)

檔案清單。如果已填入 nextPageToken,則這份清單可能不完整,而且必須擷取多頁的結果。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/drive
  • https://www.googleapis.com/auth/drive.appdata
  • 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

部分範圍受到限制,必須接受安全性評估,應用程式才能使用這些範圍。詳情請參閱授權指南

語料庫

列舉
user 使用者擁有或與他人共用的檔案。
domain 與使用者所屬網域共用的檔案。