共享云端硬盘与 My Drive API 的差异
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
共享云端硬盘的组织、共享和所有权模式与“我的云端硬盘”不同。因此,对于共享云端硬盘中的内容,系统不允许执行某些“我的云端硬盘”操作。
本指南简要介绍了 files
和 changes
资源中与共享云端硬盘相关的特定 API 差异。
文件资源
files
资源中的以下字段仅针对位于共享云端硬盘中的文件进行填充:
hasAugmentedPermissions
:是否有任何用户直接对此文件拥有文件访问权限。
capabilities/canAddFolderFromAnotherDrive
:当前用户是否可以将其他云端硬盘(其他共享云端硬盘或“我的云端硬盘”)中的文件夹添加到此文件夹。
capabilities/canDeleteChildren
:当前用户是否可以删除相应文件夹的子项。
capabilities/canMoveChildrenOutOfDrive
:当前用户是否可以将相应文件夹的子项移出共享云端硬盘。
capabilities/canMoveChildrenWithinDrive
:当前用户是否可以在共享云端硬盘中移动相应文件夹的子项。
capabilities/canMoveItemWithinDrive
:当前用户是否可以在共享云端硬盘中移动此共享云端硬盘项。
capabilities/canReadDrive
:当前用户是否对相应文件所属的共享云端硬盘具有读取权限。
capabilities/canTrashChildren
:当前用户是否可以回收此文件夹的子项。
driveId
:相应文件所在的共享云端硬盘的 ID。
trashingUser
:如果文件已被明确放入回收站,则为将其放入回收站的用户。
trashedTime
:相应项目被放入回收站的时间。如果您使用的是旧版 Drive API v2,则此字段称为 trashedDate
。
对于位于共享云端硬盘中的文件,系统不会填充以下字段:
permissions
:由于共享云端硬盘访问控制列表 (ACL) 的大小可能很大,因此权限不会作为文件的一部分返回。使用支持分页的 permissions.list
方法列出共享云端硬盘或共享云端硬盘文件夹中文件的权限。
owners
、ownerNames
、ownedByMe
:共享云端硬盘中的文件归共享云端硬盘所有,而不是归个人用户所有。
folderColorRgb
:无法单独为文件夹着色。
shared
:共享云端硬盘中的所有内容都会共享。
writersCanShare
:无法在共享云端硬盘中按角色限制共享权限。
仅当用户已获得对某个项目的访问权限时,系统才会设置以下字段:
sharedWithMeDate
sharingUser
将以下字段与共享云端硬盘搭配使用时,需要特别注意:
更改资源
共享云端硬盘的 changes
资源中新增了以下字段:
changeType
:更改类型。可能的值包括 file
和 drive
。
driveId
:与相应更改关联的共享云端硬盘的 ID。
drive
:共享云端硬盘的更新状态。如果 changeType
为 drive
且用户仍是共享云端硬盘的成员,则存在。
对于需要与共享云端硬盘同步内容或跟踪活动的应用,可能还需要进行其他更改。有关详情,请参阅跟踪用户和共享云端硬盘的更改。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Shared drive versus My Drive API differences\n\nShared drives follow different organization, sharing, and ownership models from\na My Drive. As such, some My Drive operations\naren't permitted for content in a shared drive.\n\nThis guide outlines shared drive-specific API differences in the `files` and\n`changes` resources.\n\nFile resource\n-------------\n\nThe following fields in the [`files`](/workspace/drive/api/reference/rest/v3/files) resource are\nonly populated for files located within a shared drive:\n\n- `hasAugmentedPermissions`: Whether any users are granted file access directly on this file.\n- `capabilities/canAddFolderFromAnotherDrive`: Whether the current user can add a folder from another drive (a different shared drive or My Drive) to this folder.\n- `capabilities/canDeleteChildren`: Whether the current user can delete children of this folder.\n- `capabilities/canMoveChildrenOutOfDrive`: Whether the current user can move children of this folder outside of the shared drive.\n- `capabilities/canMoveChildrenWithinDrive`: Whether the current user can move children of this folder within the shared drive.\n- `capabilities/canMoveItemWithinDrive`: Whether the current user can move this shared drive item within the shared drive.\n- `capabilities/canReadDrive`: Whether the current user has read access to the shared drive to which this file belongs.\n- `capabilities/canTrashChildren`: Whether the current user can trash children of this folder.\n- `driveId`: The ID of the shared drive where the file is located.\n- `trashingUser`: If the file has been explicitly trashed, the user who trashed it.\n- `trashedTime`: The time that the item was trashed. If you're using the older Drive API v2, this field is called `trashedDate`.\n\nThe following fields aren't populated for files located within a shared drive:\n\n- `permissions`: Due to the potential size of shared drive access control lists (ACLs), permissions aren't returned as part of files. Use the `permissions.list` method, which supports pagination, to list permissions for a file within a shared drive or the shared drive folder.\n- `owners`, `ownerNames`, `ownedByMe`: Files within a shared drive are owned by the shared drive, not individual users.\n- `folderColorRgb`: Folders cannot be colored individually.\n- `shared`: All items in a shared drive are shared.\n- `writersCanShare`: It's not possible to restrict sharing by role in shared drives.\n\nThe following fields are only set when the user has been granted file access\npermissions on an item:\n\n- `sharedWithMeDate`\n- `sharingUser`\n\nThe following fields require special consideration when you use them with shared\ndrives:\n\n- `parents.isRoot`: This field is only true for the My Drive root folder; it's false for the shared drive top-level folder.\n- `parents`: A parent doesn't appear in the parents list if the requesting\n user isn't a member of the shared drive and doesn't have access to the\n parent. In addition, with the exception of the top level folder, the parents\n list must contain exactly one item if the file is located within a shared\n drive.\n\n | **Note:** If you're using the older Drive API v2:\n | - `shareable`: Deprecated. Use `capabilities/canShare`.\n | - `editable`: Deprecated. Use `capabilities/canEdit`.\n | - `copyable`: Deprecated. Use `capabilities/canCopy`.\n | - `canComment`: Deprecated. Use `capabilities/canComment`.\n | - `canReadRevisions`: Deprecated. Use `capabilities/canReadRevisions`.\n- `capabilities/canRemoveChildren`: Use `capabilities/canDeleteChildren` or\n `capabilities/canTrashChildren`.\n\nChange resource\n---------------\n\nThe following new fields are available in the\n[`changes`](/workspace/drive/api/reference/rest/v3/changes) resource for a shared drive:\n\n- `changeType`: The change type. Possible values are `file` and `drive`.\n- `driveId`: The ID of the shared drive associated with this change.\n- `drive`: The updated state of the shared drive. Present if the `changeType` is `drive` and the user is still a member of the shared drive.\n\nAdditional changes might be required for applications that need to sync content\nwith shared drives or track activity. For details, see [Track changes for users\nand shared drives](/workspace/drive/api/guides/about-changes).\n\nRelated topics\n--------------\n\n- [Files and folders overview](/workspace/drive/api/guides/about-files)\n- [Changes and revisions overview](/workspace/drive/api/guides/change-overview)"]]