Reputation: 235
How to share file in Google Drive API v3?I have listed of file and I want to add share functionality with Laravel?
Upvotes: 1
Views: 4087
Reputation: 676
If you mean sharing a file with another user, then you can do the following
client = new Google_Client();
// setup the client the way you do
// ....
service = new Google_Service_Drive(client)
$role = 'writer';
$userEmail = '[email protected]';
$fileId = 'The ID of the file to be shared';
$userPermission = new Google_Service_Drive_Permission(array(
'type' => 'user',
'role' => $role,
'emailAddress' => $userEmail
));
$request = $service->permissions->create(
$fileId, $userPermission, array('fields' => 'id')
);
Reference:
https://developers.google.com/drive/v3/web/manage-sharing
Check my git repo for more useful examples https://github.com/sazaamout/gDrive/blob/master/gDrive.php
Upvotes: 8