问题
I'm working on file sharing on Google Drive in my android app. Here is the scenario... User A shares a file with User B, gives him/her the "writer" role. Later, forgetful User A, again, shares the same file with User B, giving him/her the "reader" role this time. My question is, will this override the first permission? or should the app handle checking of existing file permissions?
回答1:
You can use drive.permissions.update to update role
property of a permission
, provided that you have fileId
and permissionId
. The role
property will be overridden. But if you notice, there is a additionalRoles[]
property that will allow you to add secondary roles to that permission given to a user. Right now, only commenter
is allowed. Maybe in the future, more roles will be added in that property.
You can confirm by yourself using Google API Explorer:
- First, send
drive.files.list
request to getfileId
of a shared file. - Send
drive.permissions.list
request with thefileId
to getpermissionId
of a user (it is theid
in the reponse). - With
fileId
andpermissionId
, now you can usedrive.permissions.update
to change the role of that user by send the request withrole
property in the body.
来源:https://stackoverflow.com/questions/12092056/google-drive-api-adding-and-updating-permissions