Method: files.copy
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
สร้างสำเนาของไฟล์และใช้การอัปเดตที่ขอด้วยความหมายของแพตช์ ดูข้อมูลเพิ่มเติมได้ที่หัวข้อสร้างและจัดการไฟล์
คำขอ HTTP
POST https://www.googleapis.com/drive/v3/files/{fileId}/copy
URL ใช้ไวยากรณ์การแปลงรหัส gRPC
พารามิเตอร์เส้นทาง
พารามิเตอร์ |
fileId |
string
รหัสของไฟล์
|
พารามิเตอร์การค้นหา
พารามิเตอร์ |
enforceSingleParent (deprecated) |
boolean
เลิกใช้งานแล้ว: ระบบไม่รองรับการคัดลอกไฟล์ไปยังหลายโฟลเดอร์อีกต่อไป โปรดใช้แป้นพิมพ์ลัดแทน
|
ignoreDefaultVisibility |
boolean
เลือกว่าจะละเว้นการตั้งค่าระดับการมองเห็นเริ่มต้นของโดเมนสำหรับไฟล์ที่สร้างหรือไม่ ผู้ดูแลระบบโดเมนเลือกได้ว่าจะให้ไฟล์ที่อัปโหลดทั้งหมดแสดงต่อโดเมนโดยค่าเริ่มต้นหรือไม่ พารามิเตอร์นี้จะข้ามลักษณะการทำงานดังกล่าวสำหรับคำขอ ระบบจะยังคงสืบทอดสิทธิ์จากโฟลเดอร์หลัก
|
keepRevisionForever |
boolean
ว่าจะตั้งค่าฟิลด์ keepForever ในการแก้ไขส่วนหัวใหม่หรือไม่ การดำเนินการนี้ใช้ได้กับไฟล์ที่มีเนื้อหาไบนารีใน Google ไดรฟ์เท่านั้น คุณเก็บการแก้ไขไฟล์ได้ตลอดไปเพียง 200 รายการเท่านั้น หากถึงขีดจำกัดแล้ว ให้ลองลบการแก้ไขที่ปักหมุดไว้
|
ocrLanguage |
string
คำใบ้ภาษาสำหรับการประมวลผล OCR ระหว่างการนำเข้ารูปภาพ (รหัส ISO 639-1)
|
supportsAllDrives |
boolean
แอปพลิเคชันที่ขอรองรับทั้งไดรฟ์ของฉันและไดรฟ์ที่แชร์หรือไม่
|
supportsTeamDrives (deprecated) |
boolean
เลิกใช้งานแล้ว: โปรดใช้ supportsAllDrives แทน
|
includePermissionsForView |
string
ระบุสิทธิ์ของมุมมองเพิ่มเติมที่จะรวมไว้ในการตอบกลับ รองรับ published เท่านั้น
|
includeLabels |
string
รายการรหัสของป้ายกำกับที่คั่นด้วยคอมมาเพื่อรวมไว้ในส่วน labelInfo ของการตอบกลับ
|
เนื้อความของคำขอ
เนื้อความของคำขอมีอินสแตนซ์ของ File
เนื้อหาการตอบกลับ
หากทำสำเร็จ เนื้อหาการตอบกลับจะมีอินสแตนซ์ 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
ขอบเขตบางอย่างถูกจำกัดและต้องมีการประเมินความปลอดภัยเพื่อให้แอปของคุณใช้ขอบเขตเหล่านั้นได้ ดูข้อมูลเพิ่มเติมได้ที่คู่มือการให้สิทธิ์
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-27 UTC
[null,null,["อัปเดตล่าสุด 2025-08-27 UTC"],[],[],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)."]]