Method: files.copy
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
建立檔案副本,並以修補程式語意套用所有要求的更新。詳情請參閱「建立及管理檔案」。
HTTP 要求
POST https://www.googleapis.com/drive/v3/files/{fileId}/copy
這個網址使用 gRPC 轉碼語法。
查詢參數
參數 |
enforceSingleParent (deprecated) |
boolean
已淘汰:系統不再支援將檔案複製到多個資料夾。請改用快速鍵。
|
ignoreDefaultVisibility |
boolean
是否要忽略所建立檔案的網域預設顯示設定。網域管理員可以選擇預設向網域顯示所有上傳的檔案;這個參數會略過要求中的這項行為。權限仍會沿用上層資料夾的設定。
|
keepRevisionForever |
boolean
是否要在新的 HEAD 修訂版本中設定 keepForever 欄位。這項功能僅適用於 Google 雲端硬碟中有二進位內容的檔案。檔案最多只能永久保留 200 個修訂版本。如果達到上限,請嘗試刪除已釘選的修訂版本。
|
ocrLanguage |
string
圖片匯入期間,光學字元辨識 (OCR) 處理作業的語言提示 (ISO 639-1 代碼)。
|
supportsAllDrives |
boolean
要求存取的應用程式是否同時支援「我的雲端硬碟」和共用雲端硬碟。
|
supportsTeamDrives (deprecated) |
boolean
已淘汰:請改用 supportsAllDrives 。
|
includePermissionsForView |
string
指定要在回應中加入哪些額外檢視畫面權限。系統僅支援 published 。
|
includeLabels |
string
以半形逗號分隔的標籤 ID 清單,用於在回應的 labelInfo 部分中納入標籤。
|
回應主體
如果成功,回應主體會包含 File
的執行例項。
授權範圍
需要下列其中一種 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.photos.readonly
部分範圍受到限制,應用程式必須通過安全性評估才能使用。詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-27 (世界標準時間)。
[null,null,["上次更新時間:2025-08-27 (世界標準時間)。"],[],[],null,["# Method: files.copy\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\nCreates a copy of a file and applies any requested updates with patch semantics.\n\n### HTTP request\n\n`POST https://www.googleapis.com/drive/v3/files/{fileId}/copy`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|------------------------------|\n| `fileId` | `string` The ID of the file. |\n\n### Query parameters\n\n| Parameters ||\n|---------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `enforceSingleParent` | `boolean` Deprecated. Copying files into multiple folders is no longer supported. Use shortcuts instead. |\n| `ignoreDefaultVisibility` | `boolean` Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders. |\n| `keepRevisionForever` | `boolean` Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions. |\n| `ocrLanguage` | `string` A language hint for OCR processing during image import (ISO 639-1 code). |\n| `supportsAllDrives` | `boolean` Whether the requesting application supports both My Drives and shared drives. |\n| `supportsTeamDrives` **(deprecated)** | `boolean` Deprecated: Use `supportsAllDrives` instead. |\n| `includePermissionsForView` | `string` Specifies which additional view's permissions to include in the response. Only 'published' is supported. |\n| `includeLabels` | `string` A comma-separated list of IDs of labels to include in the `labelInfo` part of the response. |\n\n### Request body\n\nThe request body contains an instance of [File](/workspace/drive/api/reference/rest/v3/files#File).\n\n### Response body\n\nIf successful, the response body contains an instance of [File](/workspace/drive/api/reference/rest/v3/files#File).\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.appdata`\n- `\n https://www.googleapis.com/auth/drive.file`\n- `\n https://www.googleapis.com/auth/drive.photos.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)."]]