Method: files.generateIds
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 một tập hợp mã tệp có thể được cung cấp trong các yêu cầu chèn hoặc sao chép.
Yêu cầu HTTP
GET https://www.googleapis.com/drive/v2/files/generateIds
URL sử dụng cú pháp Chuyển mã gRPC.
Tham số truy vấn
Thông số |
maxResults |
integer
Số lượng mã nhận dạng tối đa cần trả về.
|
space |
string
Không gian mà bạn có thể sử dụng mã nhận dạng để tạo tệp mới. Giá trị được hỗ trợ là drive và appDataFolder . (Mặc định: drive )
|
type |
string
Loại mục mà mã nhận dạng có thể được dùng cho. Giá trị được hỗ trợ là files và shortcuts . Xin lưu ý rằng shortcuts chỉ được hỗ trợ trong drive space . (Mặc định: files )
|
Nội dung yêu cầu
Nội dung yêu cầu phải trống.
Nội dung phản hồi
Danh sách mã nhận dạng được tạo có thể được cung cấp trong các yêu cầu chèn
Nếu thành công, phần nội dung phản hồi sẽ chứa dữ liệu có cấu trúc sau:
Biểu diễn dưới dạng JSON |
{
"ids": [
string
],
"space": string,
"kind": string
} |
Trường |
ids[] |
string
Mã nhận dạng được tạo cho người dùng yêu cầu trong không gian được chỉ định.
|
space |
string
Loại tệp có thể tạo bằng các mã nhận dạng này.
|
kind |
string
Giá trị này luôn là drive#generatedIds
|
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.file
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.generateIds\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.GeneratedIds.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nGenerates a set of file IDs which can be provided in insert or copy requests.\n\n### HTTP request\n\n`GET https://www.googleapis.com/drive/v2/files/generateIds`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Query parameters\n\n| Parameters ||\n|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `maxResults` | `integer` Maximum number of IDs to return. |\n| `space` | `string` The space in which the IDs can be used to create new files. Supported values are `drive` and `appDataFolder`. (Default: `drive`) |\n| `type` | `string` The type of items which the IDs can be used for. Supported values are `files` and `shortcuts`. Note that `shortcuts` are only supported in the `drive` `space`. (Default: `files`) |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nA list of generated IDs which can be provided in insert requests\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|----------------------------------------------------------------|\n| ``` { \"ids\": [ string ], \"space\": string, \"kind\": string } ``` |\n\n| Fields ||\n|---------|----------------------------------------------------------------------------|\n| `ids[]` | `string` The IDs generated for the requesting user in the specified space. |\n| `space` | `string` The type of file that can be created with these IDs. |\n| `kind` | `string` This is always `drive#generatedIds` |\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.file`\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)."]]