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 một tệp và áp dụng mọi nội dung cập nhật được yêu cầu bằng ngữ nghĩa bản vá. Để biết thêm thông tin, hãy xem bài viết Tạo và quản lý tệp.
Yêu cầu HTTP
POST https://www.googleapis.com/drive/v3/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.
|
Tham số truy vấn
Thông số |
enforceSingleParent (deprecated) |
boolean
Không dùng nữa: 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.
|
ignoreDefaultVisibility |
boolean
Có bỏ qua chế độ cài đặt mặc định về chế độ hiển thị của miền đối với tệp đã tạo hay không. Theo mặc định, quản trị viên miền có thể chọn hiển thị tất cả các tệp đã tải lên cho miền; tham số này bỏ qua hành vi đó cho yêu cầu. Các quyền vẫn được kế thừa từ thư mục mẹ.
|
keepRevisionForever |
boolean
Có đặt trường keepForever trong bản sửa đổi tiêu đề mới hay không. Điều này chỉ áp dụng cho các tệp có nội dung nhị phân trong Google Drive. Bạn chỉ có thể giữ vĩnh viễn 200 bản sửa đổi cho tệp. Nếu bạn đã đạt đến giới hạn, hãy thử xoá các bản sửa đổi được ghim.
|
ocrLanguage |
string
Gợi ý về ngôn ngữ để xử lý OCR trong quá trình nhập hình ảnh (mã ISO 639-1).
|
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: Thay vào đó, hãy sử dụng supportsAllDrives .
|
includePermissionsForView |
string
Chỉ định những quyền xem 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 phân tách bằng dấu phẩy của các nhãn cần đư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/drive
https://www.googleapis.com/auth/drive.appdata
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 bạn phải đánh giá bảo mật để ứng dụng của bạn có thể sử dụng các phạm vi đó. Để 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-08-27 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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)."]]