Method: files.download
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
下載檔案內容。詳情請參閱「下載及匯出檔案」。
作業效期為建立當天起算的 24 小時內。
HTTP 要求
POST https://www.googleapis.com/drive/v3/files/{fileId}/download
這個網址使用 gRPC 轉碼語法。
路徑參數
參數 |
fileId |
string
必要欄位。要下載的檔案 ID。
|
查詢參數
參數 |
mimeType |
string
(選用步驟) 檔案應下載的 MIME 類型。只有在下載 Google Workspace 文件時,才能設定這個欄位。如需支援的 MIME 類型清單,請參閱「匯出 Google Workspace 文件的 MIME 類型」。如未設定,系統會以預設 MIME 類型下載 Google Workspace 文件。預設 MIME 類型日後可能會變更。
|
revisionId |
string
(選用步驟) 要下載的檔案修訂版本 ID。只有在下載 Blob 檔案、Google 文件和 Google 試算表時,才能設定這個欄位。如果系統不支援下載檔案的特定修訂版本,則會傳回 INVALID_ARGUMENT 。
|
回應主體
如果成功,回應主體會包含 Operation
的執行例項。
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.readonly
部分範圍受到限制,應用程式必須通過安全性評估才能使用。詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-27 (世界標準時間)。
[null,null,["上次更新時間:2025-08-27 (世界標準時間)。"],[],[],null,["# Method: files.download\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nDownloads content of a file. Operations are valid for 24 hours from the time of creation.\n\n### HTTP request\n\n`POST https://www.googleapis.com/drive/v3/files/{fileId}/download`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|----------------------------------------------------|\n| `fileId` | `string` Required. The ID of the file to download. |\n\n### Query parameters\n\n| Parameters ||\n|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mimeType` | `string` Optional. The MIME type the file should be downloaded as. This field can only be set when downloading Google Workspace documents. See [files.export MIME types for Google Workspace documents](/drive/api/guides/ref-export-formats) for the list of supported MIME types. If not set, a Google Workspace document is downloaded with a default MIME type. The default MIME type might change in the future. |\n| `revisionId` | `string` Optional. The revision ID of the file to download. This field can only be set when downloading blob files, Google Docs, and Google Sheets. Returns `INVALID_ARGUMENT` if downloading a specific revision on the file is unsupported. |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nIf successful, the response body contains an instance of [Operation](/workspace/drive/api/reference/rest/v3/operations#Operation).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/drive`\n- `\n https://www.googleapis.com/auth/drive.file`\n- `\n https://www.googleapis.com/auth/drive.readonly`\n\nSome scopes are restricted and require a security assessment for your app to use them. For more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]