【发布时间】:2019-08-04 08:51:48
【问题描述】:
我想通过 google 提供的 php 客户端为 google drive 上的 zip 文件生成一个可共享链接。
使用 Google Drive 的 php 客户端我可以设置权限(通过查看驱动器 gui 中的文件权限确认):
$config = [
'type' => 'anyone',
'role' => 'reader',
'withLink' => true,
//'allowFileDiscovery' => false
];
$tempPermission = new Google_Service_Drive_Permission($config);
$ret = $this->service->permissions->create($file, $tempPermission);
echo '<pre>';
print_r($ret);
$files = $this->service->files->get($file);
print_R($files);
但是我不确定从这里去哪里获取物理 url。
这是设置perm后文件对象的输出:
Google_Service_Drive_DriveFile Object
(
[collection_key:protected] => spaces
[appProperties] =>
[capabilitiesType:protected] => Google_Service_Drive_DriveFileCapabilities
[capabilitiesDataType:protected] =>
[contentHintsType:protected] => Google_Service_Drive_DriveFileContentHints
[contentHintsDataType:protected] =>
[copyRequiresWriterPermission] =>
[createdTime] =>
[description] =>
[driveId] =>
[explicitlyTrashed] =>
[exportLinks] =>
[fileExtension] =>
[folderColorRgb] =>
[fullFileExtension] =>
[hasAugmentedPermissions] =>
[hasThumbnail] =>
[headRevisionId] =>
[iconLink] =>
[id] => 1CU_nTm06ATlf2s54890oY62NyEzCGgyf
[imageMediaMetadataType:protected] => Google_Service_Drive_DriveFileImageMediaMetadata
[imageMediaMetadataDataType:protected] =>
[isAppAuthorized] =>
[kind] => drive#file
[lastModifyingUserType:protected] => Google_Service_Drive_User
[lastModifyingUserDataType:protected] =>
[md5Checksum] =>
[mimeType] => application/zip
[modifiedByMe] =>
[modifiedByMeTime] =>
[modifiedTime] =>
[name] => restorepoint_2019_08_02_07_32_57.zip
[originalFilename] =>
[ownedByMe] =>
[ownersType:protected] => Google_Service_Drive_User
[ownersDataType:protected] => array
[parents] =>
[permissionIds] =>
[permissionsType:protected] => Google_Service_Drive_Permission
[permissionsDataType:protected] => array
[properties] =>
[quotaBytesUsed] =>
[shared] =>
[sharedWithMeTime] =>
[sharingUserType:protected] => Google_Service_Drive_User
[sharingUserDataType:protected] =>
[size] =>
[spaces] =>
[starred] =>
[teamDriveId] =>
[thumbnailLink] =>
[thumbnailVersion] =>
[trashed] =>
[trashedTime] =>
[trashingUserType:protected] => Google_Service_Drive_User
[trashingUserDataType:protected] =>
[version] =>
[videoMediaMetadataType:protected] => Google_Service_Drive_DriveFileVideoMediaMetadata
[videoMediaMetadataDataType:protected] =>
[viewedByMe] =>
[viewedByMeTime] =>
[viewersCanCopyContent] =>
[webContentLink] =>
[webViewLink] =>
[writersCanShare] =>
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
)
如果有人能弄清楚如何设置从生成时间起一小时后到期的权限(在文档中找不到任何关于此的信息关于 php 客户端) .
【问题讨论】:
标签: php google-drive-api google-client