Method: files.modifyLabels
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
修改套用至檔案的標籤集。傳回已新增或修改的標籤清單。
HTTP 要求
POST https://www.googleapis.com/drive/v2/files/{fileId}/modifyLabels
這個網址使用 gRPC 轉碼語法。
路徑參數
參數 |
fileId |
string
標籤所屬檔案的 ID。
|
回應主體
對 files.modifyLabels 要求的相關回應。其中只包含要求新增或更新的標籤。
如果成功,回應主體會含有以下結構的資料:
JSON 表示法 |
{
"modifiedLabels": [
{
object (Label )
}
],
"kind": string
} |
欄位 |
modifiedLabels[] |
object (Label )
要求新增或更新的標籤清單。
|
kind |
string
這項值一律為 drive#modifyLabelsResponse
|
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.metadata
部分範圍受到限制,應用程式必須通過安全性評估才能使用。詳情請參閱授權指南。
ModifyLabelsRequest
要求修改檔案的標籤集。這項要求可能包含多項修改,這些修改會以不可分割的形式全數成功或全數失敗。
JSON 表示法 |
{
"labelModifications": [
{
object (LabelModification )
}
],
"kind": string
} |
欄位 |
labelModifications[] |
object (LabelModification )
要套用至檔案標籤的修改清單。
|
kind |
string
這個值一律為 drive#modifyLabelsRequest 。
|
LabelModification
修改檔案標籤。LabelModification 可用於將標籤套用至檔案、更新檔案上的現有標籤,或從檔案中移除標籤。
JSON 表示法 |
{
"fieldModifications": [
{
object (FieldModification )
}
],
"labelId": string,
"removeLabel": boolean,
"kind": string
} |
欄位 |
fieldModifications[] |
object (FieldModification )
這個標籤欄位的修改清單。
|
labelId |
string
要修改的標籤 ID。
|
removeLabel |
boolean
如果是 true,系統會從檔案移除標籤。
|
kind |
string
這個值一律為 drive#labelModification 。
|
FieldModification
JSON 表示法 |
{
"setDateValues": [
string
],
"setTextValues": [
string
],
"setSelectionValues": [
string
],
"setIntegerValues": [
string
],
"setUserValues": [
string
],
"fieldId": string,
"kind": string,
"unsetValues": boolean
} |
欄位 |
setDateValues[] |
string
將 date 欄位的值替換為這些新值。字串必須採用 RFC 3339 完整日期格式:YYYY-MM-DD。
|
setTextValues[] |
string
設定 text 欄位的值。
|
setSelectionValues[] |
string
以這些新值取代 selection 欄位。
|
setIntegerValues[] |
string (int64 format)
以這些新值取代 integer 欄位的值。
|
setUserValues[] |
string
以這些新值取代 user 欄位。值必須是有效的電子郵件地址。
|
fieldId |
string
要修改的欄位 ID。
|
kind |
string
這個值一律為 drive#labelFieldModification 。
|
unsetValues |
boolean
取消設定這個欄位的值。
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[],[],null,["# Method: files.modifyLabels\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.ModifyLabelsResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [ModifyLabelsRequest](#ModifyLabelsRequest)\n - [JSON representation](#ModifyLabelsRequest.SCHEMA_REPRESENTATION)\n- [LabelModification](#LabelModification)\n - [JSON representation](#LabelModification.SCHEMA_REPRESENTATION)\n- [FieldModification](#FieldModification)\n - [JSON representation](#FieldModification.SCHEMA_REPRESENTATION)\n- [Try it!](#try-it)\n\nModifies the set of labels applied to a file. Returns a list of the labels that were added or modified.\n\n### HTTP request\n\n`POST https://www.googleapis.com/drive/v2/files/{fileId}/modifyLabels`\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 which the labels belong. |\n\n### Request body\n\nThe request body contains an instance of [ModifyLabelsRequest](/workspace/drive/api/reference/rest/v2/files/modifyLabels#ModifyLabelsRequest).\n\n### Response body\n\nResponse to a files.modifyLabels request. This contains only those labels which were added or updated by the request.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------|\n| ``` { \"modifiedLabels\": [ { object (/workspace/drive/api/reference/rest/v2/Label) } ], \"kind\": string } ``` |\n\n| Fields ||\n|--------------------|-----------------------------------------------------------------------------------------------------------------------------------|\n| `modifiedLabels[]` | `object (`[Label](/workspace/drive/api/reference/rest/v2/Label)`)` The list of labels which were added or updated by the request. |\n| `kind` | `string` This is always `drive#modifyLabelsResponse` |\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.file`\n- `\n https://www.googleapis.com/auth/drive.metadata`\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).\n\nModifyLabelsRequest\n-------------------\n\nA request to modify the set of labels on a file. This request may contain many modifications that will either all succeed or all fail atomically.\n\n| JSON representation |\n|------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"labelModifications\": [ { object (/workspace/drive/api/reference/rest/v2/files/modifyLabels#LabelModification) } ], \"kind\": string } ``` |\n\n| Fields ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `labelModifications[]` | `object (`[LabelModification](/workspace/drive/api/reference/rest/v2/files/modifyLabels#LabelModification)`)` The list of modifications to apply to the labels on the file. |\n| `kind` | `string` This is always `drive#modifyLabelsRequest`. |\n\nLabelModification\n-----------------\n\nA modification to a label on a file. A LabelModification can be used to apply a label to a file, update an existing label on a file, or remove a label from a file.\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"fieldModifications\": [ { object (/workspace/drive/api/reference/rest/v2/files/modifyLabels#FieldModification) } ], \"labelId\": string, \"removeLabel\": boolean, \"kind\": string } ``` |\n\n| Fields ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `fieldModifications[]` | `object (`[FieldModification](/workspace/drive/api/reference/rest/v2/files/modifyLabels#FieldModification)`)` The list of modifications to this label's fields. |\n| `labelId` | `string` The ID of the label to modify. |\n| `removeLabel` | `boolean` If true, the label will be removed from the file. |\n| `kind` | `string` This is always `drive#labelModification`. |\n\nFieldModification\n-----------------\n\nA modification to a label's field.\n\n| JSON representation |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"setDateValues\": [ string ], \"setTextValues\": [ string ], \"setSelectionValues\": [ string ], \"setIntegerValues\": [ string ], \"setUserValues\": [ string ], \"fieldId\": string, \"kind\": string, \"unsetValues\": boolean } ``` |\n\n| Fields ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `setDateValues[]` | `string` Replaces the value of a `date` field with these new values. The string must be in the RFC 3339 full-date format: YYYY-MM-DD. |\n| `setTextValues[]` | `string` Sets the value of a `text` field. |\n| `setSelectionValues[]` | `string` Replaces a `selection` field with these new values. |\n| `setIntegerValues[]` | `string (`[int64](https://developers.google.com/discovery/v1/type-format)` format)` Replaces the value of an `integer` field with these new values. |\n| `setUserValues[]` | `string` Replaces a `user` field with these new values. The values must be valid email addresses. |\n| `fieldId` | `string` The ID of the field to be modified. |\n| `kind` | `string` This is always `drive#labelFieldModification`. |\n| `unsetValues` | `boolean` Unsets the values for this field. |"]]