Sự khác biệt giữa API Bộ nhớ dùng chung và API Drive của tôi
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.
Bộ nhớ dùng chung có các mô hình tổ chức, chia sẻ và quyền sở hữu khác với Drive của tôi. Do đó, một số thao tác trong Drive của tôi không được phép thực hiện đối với nội dung trong bộ nhớ dùng chung.
Hướng dẫn này trình bày những điểm khác biệt về API dành riêng cho bộ nhớ dùng chung trong các tài nguyên files
và changes
.
Tài nguyên tệp
Các trường sau trong tài nguyên files
chỉ được điền sẵn cho các tệp nằm trong bộ nhớ dùng chung:
hasAugmentedPermissions
: Liệu có người dùng nào được cấp quyền truy cập trực tiếp vào tệp này hay không.
capabilities/canAddFolderFromAnotherDrive
: Liệu người dùng hiện tại có thể thêm một thư mục từ một ổ đĩa khác (một bộ nhớ dùng chung khác hoặc Ổ đĩa của tôi) vào thư mục này hay không.
capabilities/canDeleteChildren
: Liệu người dùng hiện tại có thể xoá các thư mục con của thư mục này hay không.
capabilities/canMoveChildrenOutOfDrive
: Người dùng hiện tại có thể di chuyển các thư mục con của thư mục này ra ngoài bộ nhớ dùng chung hay không.
capabilities/canMoveChildrenWithinDrive
: Người dùng hiện tại có thể di chuyển các thư mục con của thư mục này trong bộ nhớ dùng chung hay không.
capabilities/canMoveItemWithinDrive
: Người dùng hiện tại có thể di chuyển mục này trong bộ nhớ dùng chung hay không.
capabilities/canReadDrive
: Người dùng hiện tại có quyền đọc đối với bộ nhớ dùng chung mà tệp này thuộc về hay không.
capabilities/canTrashChildren
: Người dùng hiện tại có thể chuyển các thư mục con của thư mục này vào thùng rác hay không.
driveId
: Mã nhận dạng của ổ đĩa dùng chung nơi lưu trữ tệp.
trashingUser
: Nếu tệp đã bị chuyển vào thùng rác một cách rõ ràng, thì đó là người dùng đã chuyển tệp đó vào thùng rác.
trashedTime
: Thời gian xoá mục vào thùng rác. Nếu bạn đang sử dụng Drive API phiên bản 2 cũ, thì trường này có tên là trashedDate
.
Các trường sau đây không được điền sẵn cho những tệp nằm trong bộ nhớ dùng chung:
permissions
: Do kích thước tiềm năng của danh sách kiểm soát quyền truy cập (ACL) của bộ nhớ dùng chung, nên quyền không được trả về dưới dạng một phần của tệp. Sử dụng phương thức permissions.list
(có hỗ trợ phân trang) để liệt kê các quyền đối với một tệp trong bộ nhớ dùng chung hoặc thư mục của bộ nhớ dùng chung.
owners
, ownerNames
, ownedByMe
: Tệp trong ổ đĩa dùng chung thuộc sở hữu của ổ đĩa dùng chung chứ không phải người dùng cá nhân.
folderColorRgb
: Bạn không thể tô màu từng thư mục.
shared
: Tất cả các mục trong một bộ nhớ dùng chung đều được chia sẻ.
writersCanShare
: Bạn không thể hạn chế việc chia sẻ theo vai trò trong ổ đĩa dùng chung.
Các trường sau đây chỉ được đặt khi người dùng đã được cấp quyền truy cập vào tệp đối với một mục:
sharedWithMeDate
sharingUser
Bạn cần cân nhắc đặc biệt đối với các trường sau khi sử dụng chúng với ổ đĩa dùng chung:
parents.isRoot
: Trường này chỉ đúng với thư mục gốc của Drive của tôi; trường này sai với thư mục cấp cao nhất của bộ nhớ dùng chung.
parents
: Cha mẹ sẽ không xuất hiện trong danh sách cha mẹ nếu người dùng yêu cầu không phải là thành viên của bộ nhớ dùng chung và không có quyền truy cập vào cha mẹ. Ngoài ra, ngoại trừ thư mục cấp cao nhất, danh sách parents phải chứa đúng một mục nếu tệp nằm trong bộ nhớ dùng chung.
capabilities/canRemoveChildren
: Sử dụng capabilities/canDeleteChildren
hoặc capabilities/canTrashChildren
.
Thay đổi tài nguyên
Các trường mới sau đây có trong tài nguyên changes
cho bộ nhớ dùng chung:
changeType
: Loại thay đổi. Các giá trị có thể có là file
và drive
.
driveId
: Mã nhận dạng của bộ nhớ dùng chung được liên kết với thay đổi này.
drive
: Trạng thái mới của bộ nhớ dùng chung. Xuất hiện nếu changeType
là drive
và người dùng vẫn là thành viên của bộ nhớ dùng chung.
Có thể bạn cần thực hiện các thay đổi khác đối với những ứng dụng cần đồng bộ hoá nội dung với ổ đĩa dùng chung hoặc theo dõi hoạt động. Để biết thông tin chi tiết, hãy xem bài viết Theo dõi các thay đổi đối với người dùng và bộ nhớ dùng chung.
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-29 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[],[],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)"]]