How to know through APIs who created the file in Shared Drive (Team Drive) in Google Drive

混江龙づ霸主 提交于 2021-02-10 22:24:44

问题


All the files in Shared drive (Team Drive) in google drive are accessible by all users who have access to Shared Drive (Team Drive).

When a new file is created in a Shared Drive(Team Drive) by default all the users with access to Shared Drive(Team Drive) will become owners as well.

Question : when we list the files using APIs inside a folder in Shared Drive (Team Drive), how to detect who created the file ?


回答1:


You can use the Revisions API

So, if you list the revisions of a file specifying revisions/lastModifyingUser, revisions/id in parameter fields, you can retrieve the changes of the file and the corresponding user who modified the file.

Thereby, the first revision ("id": "1") should correspond to the creation / upload of the file and the related lastModifyingUser is the creator of the file.

Additional information:

  • Listing files, will return a files resource with the properties as specified here - The resource has properties like "owners" or "lastModifyingUser", but unfortunately not "creator"
  • There is already a feature request asking to implement the option to retrieve the user who added a file to a shared drive. - You can "star" it to increase visibility and thus hopefully sooner implementation
  • Until then unfortunately you cannot retrieve the file creator without the workaround with the Revisions API


来源:https://stackoverflow.com/questions/62666869/how-to-know-through-apis-who-created-the-file-in-shared-drive-team-drive-in-go

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!