ivanvermeyen / laravel-google-drive-demo

Laravel & Google Drive Storage - Demo project with Laravel 5.4
403 stars 155 forks source link

Delete Permissions #86

Open alxBlues opened 4 years ago

alxBlues commented 4 years ago

Sorry, somebody can show me a example for delete permissions, i need change of public to private file. Thanks

ivanvermeyen commented 4 years ago

Hi,

You'll have to do some digging, but hopefully this sets you on track:

Here is sample code to create and add permissions.

The permissions object also has a delete method:

delete( string $fileId, string $permissionId, array $optParams = array() )

https://developers.google.com/resources/api-libraries/documentation/drive/v3/php/latest/class-Google_Service_Drive_Permissions_Resource.html

You have to feed it the file ID and permission ID, so you'll need to figure out how to get those...

The file object has a getPermissions() method:

https://developers.google.com/resources/api-libraries/documentation/drive/v3/php/latest/class-Google_Service_Drive_DriveFile.html

Sorry that I can't be more specific, but I can't go deep into the API figure it out myself. It's also a bit more advanced than what this demo project was supposed to cover :)

Let us know if you get it to work tho, other people might benefit from it :)