Method: files.copy
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tạo bản sao của tệp đã chỉ định.
Yêu cầu HTTP
POST https://www.googleapis.com/drive/v2/files/{fileId}/copy
URL sử dụng cú pháp Chuyển mã gRPC.
Tham số đường dẫn
Thông số |
fileId |
string
Mã nhận dạng của tệp cần sao chép.
|
Tham số truy vấn
Thông số |
convert |
boolean
Liệu có chuyển đổi tệp này sang định dạng tương ứng của Trình chỉnh sửa Tài liệu hay không.
|
enforceSingleParent (deprecated) |
boolean
Ngừng sử dụng: Tính năng sao chép tệp vào nhiều thư mục không còn được hỗ trợ. Thay vào đó, hãy sử dụng phím tắt.
|
ocr |
boolean
Liệu có nên thử OCR trên tệp .jpg, .png, .gif hoặc .pdf được tải lên hay không.
|
ocrLanguage |
string
Nếu ocr là đúng, hãy gợi ý về ngôn ngữ cần sử dụng. Các giá trị hợp lệ là mã BCP 47.
|
pinned |
boolean
Liệu có ghim bản sửa đổi đầu tiên của bản sao mới hay không. Một tệp có thể có tối đa 200 bản sửa đổi được ghim.
|
supportsAllDrives |
boolean
Liệu ứng dụng yêu cầu có hỗ trợ cả Drive của tôi và bộ nhớ dùng chung hay không.
|
supportsTeamDrives (deprecated) |
boolean
Không dùng nữa: Hãy sử dụng supportsAllDrives .
|
timedTextLanguage |
string
Ngôn ngữ của văn bản có thời gian.
|
timedTextTrackName |
string
Tên của bản nhạc có văn bản được căn chỉnh theo thời gian.
|
visibility |
enum (Visibility )
Chế độ hiển thị của tệp mới. Tham số này chỉ liên quan khi nguồn không phải là Google Tài liệu gốc và convert=false.
|
includePermissionsForView |
string
Chỉ định quyền của thành phần hiển thị bổ sung cần đưa vào phản hồi. Chỉ hỗ trợ published .
|
includeLabels |
string
Danh sách mã nhận dạng của các nhãn được phân tách bằng dấu phẩy để đưa vào phần labelInfo của phản hồi.
|
Nội dung yêu cầu
Nội dung yêu cầu chứa một bản sao của File
.
Nội dung phản hồi
Nếu thành công, nội dung phản hồi sẽ chứa một phiên bản của File
.
Phạm vi uỷ quyền
Yêu cầu một trong các phạm vi OAuth sau:
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.photos.readonly
Một số phạm vi bị hạn chế và yêu cầu đánh giá bảo mật để ứng dụng của bạn có thể sử dụng. Để biết thêm thông tin, hãy xem Hướng dẫn uỷ quyền.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 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 the specified file.\n\n### HTTP request\n\n`POST https://www.googleapis.com/drive/v2/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 to copy. |\n\n### Query parameters\n\n| Parameters ||\n|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `convert` | `boolean` Whether to convert this file to the corresponding Docs Editors format. |\n| `enforceSingleParent` **(deprecated)** | `boolean` Deprecated: Copying files into multiple folders is no longer supported. Use shortcuts instead. |\n| `ocr` | `boolean` Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads. |\n| `ocrLanguage` | `string` If `ocr` is true, hints at the language to use. Valid values are BCP 47 codes. |\n| `pinned` | `boolean` Whether to pin the head revision of the new copy. A file can have a maximum of 200 pinned revisions. |\n| `supportsAllDrives` | `boolean` Whether the requesting application supports both My Drives and shared drives. |\n| `supportsTeamDrives` **(deprecated)** | `boolean` Deprecated: Use `supportsAllDrives` instead. |\n| `timedTextLanguage` | `string` The language of the timed text. |\n| `timedTextTrackName` | `string` The timed text track name. |\n| `visibility` | `enum (`[Visibility](/workspace/drive/api/reference/rest/v2/Visibility)`)` The visibility of the new file. This parameter is only relevant when the source is not a native Google Doc and convert=false. |\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/v2/files#File).\n\n### Response body\n\nIf successful, the response body contains an instance of [File](/workspace/drive/api/reference/rest/v2/files#File).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/docs`\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.apps.readonly`\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)."]]