Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change file permissions to Google Drive with Javascript

This is the first time I write. I come to you for the marvelous solutions to all the problems you find.

I built my site Google Drive, with its SDK for Javascript. Everything works incredibly well, only I have a problem. I need to change the permissions of a file to "publish, for everyone without identifying" the files that I want.

I looked at the sdk Google Drive is:

https://developers.google.com/drive/v2/reference/permissions/update

But I find it very complex to understand, do not know where I get the variables.

function updatePermission(fileId, permissionId, newRole) {
  // First retrieve the permission from the API.
  var request = gapi.client.drive.permissions.get({
    'fileId': fileId,
    'permissionId': permissionId
  });
  request.execute(function(resp) {
    resp.role = newRole;
    var updateRequest = gapi.client.drive.permissions.update({
      'fileId': fileId,
      'permissionId': permissionId,
      'resource': resp
    });
    updateRequest.execute(function(resp) { });
  });
}

I do not understand where I draw the variables: -permissionId -newRole (for set super public file)

Currently I have all the information of the files (id, urls ...), but I find it very complex to change permissions.

I searched a lot for Google, but can not find any example to locate a file in public.

Does anyone know? ... I really appreciate the heart.

Currently I upload the files to the user's account without any problem, I can also play the files without problem. I just have this little thing, haha.

like image 503
0123 Avatar asked Nov 13 '22 00:11

0123


1 Answers

According to this post, you need to assign the reader permission to the role anyone.

like image 62
Ron Romero Avatar answered Nov 14 '22 23:11

Ron Romero