How to set creating google doc in gdrive using PHP as read only file -


i creating txt/html file in google drive document using google drive sdk. code creates document. question is possible can set file permission read-only file?

this code in creating document,

$mkfile = $this->_service->files->insert($file, array('data' => $subcontent, 'mimetype' => 'text/html', 'convert' => true));

you can use permissions.patch update permissions file after has been inserted. there bug in api doesn't allow set permissions @ time insert file. have patch them after file has been placed on drive.

code ripped documentation link above.

/**  * patch permission's role.  *  * @param google_service_drive $service drive api service instance.  * @param string $fileid id of file update permission for.  * @param string $permissionid id of permission patch.  * @param string $newrole value "owner", "writer" or "reader".  * @return google_servie_drive_permission patched permission. null  *     returned if api error occurred.  */ function patchpermission($service, $fileid, $permissionid, $newrole) {   $patchedpermission = new google_service_drive_permission();   $patchedpermission->setrole($newrole);   try {     return $service->permissions->patch($fileid, $permissionid, $patchedpermission);   } catch (exception $e) {     print "an error occurred: " . $e->getmessage();   }   return null; } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -