标签概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
标签是您指定的元数据,可帮助用户整理和查找 Google 云端硬盘中的文件,以及针对这些文件应用政策。借助 Drive API,开发者可以为文件和文件夹应用标签、设置标签字段值、读取文件上的标签和字段值,以及使用自定义标签分类法定义的元数据术语搜索文件。
云端硬盘标签可通过将元数据附加到文件和文件夹来支持业务流程。标签的常见用途包括:
将内容分类以遵循信息治理策略 - 创建标签以标识敏感内容或需要特殊处理的数据。
例如,您可以创建一个名为“敏感度”的带标记的标签(具有颜色编码的选项值的标签),其值为“绝密”“机密”和“公开”。
为云端硬盘中的内容应用政策 - 创建标签,以便在云端硬盘内容的整个生命周期内对其进行管理,并确保其遵循贵组织的记录保留做法。例如,使用标签来管理数据泄露防护 (DLP) 政策,根据该政策,用户无法下载“敏感度”标签设置为“绝密”的文件。
挑选和查找文件 - 创建标签,让贵组织中的用户可以根据标签及其字段查找内容,从而提高公司内容的可搜索性。例如,将“签字状态”标签集中的“待签字”标签应用于特定日期之前待签字的所有合同。这样一来,当有人搜索“等待签名”时,云端硬盘搜索便可返回这些合同。
以下是云端硬盘标签使用的常见术语:
- 标签
放置在云端硬盘文件上的结构化元数据。
云端硬盘用户可以为文件分配标签并设置标签字段值。标签由以下部分组成:
- 标签名称
- 标签的资源名称。标签 ID 是标签名称的一部分。根据请求的不同,名称采用以下两种形式之一:
labels/{id}
或 labels/{id}@{revisionId}
。如需了解详情,请参阅下文中的标签修订版本。
- 标签 ID
- 标签的全局唯一标识符。ID 是标签名称的一部分,但与名称不同,它在修订版本之间保持一致。
- 字段
标签的单个可设置的类型化组成部分。一个标签可以关联零个或多个字段。如果字段在 Google Drive Labels API 中配置了 ListOptions
,则选择字段和用户字段可以设置多个值。
- 字段类型
- 与字段关联的值的数据类型。可配置为整数、dateString、文本、用户或选择。所选类型会影响适用于 Google 云端硬盘项目的有效值和可用的搜索查询选项。
- 标签分类
用户可用于云端硬盘文件的已配置标签字段。可通过 Drive Labels API 读取和写入。也称为标签架构。
- 标签修订
标签的实例。每次创建、更新、发布或弃用标签时,标签修订版本都会递增。
- 草稿修订版本
- 标签当前草稿实例的修订版本号。您可以对标签进行多次更新,每次更新都会增加其草稿修订版本号,但不会影响已发布的修订版本。借助草稿标签功能,您可以在发布之前测试标签更新。
- 已发布的修订版本
- 已发布标签版本的修订版本号。已发布的标签是可供用户使用的标签实例。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-04。
[null,null,["最后更新时间 (UTC):2025-08-04。"],[],[],null,["# Labels overview\n\n*Labels* are metadata that you define to help users organize, find, and apply\npolicy to files in Google Drive. The Drive API allows developers to\napply labels to files and folders, set label field values, read labels and field\nvalues on files, and search for files using metadata terms defined by the custom\nlabel taxonomy.\n\nDrive labels can support business processes by attaching metadata\nto files and folders. Common uses for labels are:\n\n- **Classify content to follow an information governance strategy**---Create a\n label to identify sensitive content or data that requires special handling.\n For example, you might create a badged label (a label with color-coded\n option values) titled \"Sensitivity\" with the values of \"Top Secret,\"\n \"Confidential,\" and \"Public.\"\n\n- **Apply policy to items in Drive**---Create labels to manage\n Drive content throughout its lifecycle and ensure it adheres\n to your organization's record keeping practices. For example, use labels to\n manage a data loss policy (DLP) whereby users can't download files with a\n \"Sensitivity\" label set to \"Top Secret\".\n\n- **Curate and find files**---Create labels to increase searchability of your\n company's content by letting people in your organization find items based on\n labels and their fields. For example, apply a \"Signature Status\" label set\n to \"Awaiting Signature\" to all contracts awaiting signature by a specific\n date. Drive search can then return these contracts when\n someone searches \"awaiting signature\".\n\nBelow is a list of common terms used by Drive labels:\n\n*Label*\n\n: Structured metadata placed on a Drive file.\n Drive users can assign labels and set label field values\n for files. Labels are composed of:\n\n *Label name*\n : The resource name of the label. The *label ID* is part of the\n Label name. Depending on the request, the name is in the form of either:\n `labels/{id}` or `labels/{id}@{revisionId}`. For more information, see\n [Label revision](#revision) below.\n\n *Label ID*\n : A globally unique identifier for the label. The ID is part of the\n label name, but unlike the name, it's consistent between revisions.\n\n*Field*\n\n: An individual typed, settable component of a label. A label can have zero or\n more fields associated with it. Selection and user fields can be set with\n multiple values if the field is configured with\n [`ListOptions`](/workspace/drive/labels/reference/rest/v2/labels#listoptions) in the\n [Google Drive Labels API](/workspace/drive/labels/guides/overview).\n\n *Field type*\n : The data type of the value associated with the *field*. Configurable as\n integer, dateString, text, user, or selection. The type chosen impacts\n both the valid values applicable to Drive items and the\n search query options available.\n\n*Label taxonomy*\n\n: The configured label fields available to users for application to\n Drive files. Readable and writable through the\n Drive Labels API. Also known as the label schema.\n\n*Label revision*\n\n: An instance of the label. Anytime a label is created, updated, published, or\n deprecated, the label revision increments.\n\n *Draft revision*\n : The revision number of the current draft instance of the label. You can\n make several updates to a label, each incrementing its draft revision\n number, without affecting the published revision. The ability to have\n draft labels lets you test label updates before publishing.\n\n *Published revision*\n : The revision number of the published version of a label. The published\n label is the instance of the label available to users.\n\nRelated topics\n--------------\n\n- To learn about using labels in Drive, see [Set a label field\n on a file](/workspace/drive/api/guides/set-label).\n- Learn more about the [Drive Labels API](/workspace/drive/labels/guides/overview)."]]