如何设置labels.restricted /想要限制文件在Google云端硬盘中下载

时间:2015-04-19 20:07:17

标签: php google-drive-api

以下是labels.restricted下的参数:

https://developers.google.com/drive/v2/reference/files/insert

但无法在PHP中编写代码几乎可以尝试所有内容,但仍会从google驱动器API中获取错误。

$file = new Google_Service_Drive_DriveFile();
$file->setTitle(TESTFILE);

$file->setRestricted();

$result = $service->files->insert(
  $file,
  array(
    'data' => file_get_contents(TESTFILE),
    'mimeType' => 'application/octet-stream',
    'uploadType' => 'multipart'
    //
    // HERE SHOULD BE THE CODE FOR THE labels.restricted
    //
  )
);

1 个答案:

答案 0 :(得分:0)

您必须在标签上设置setRestricted:

$label = new Google_Service_Drive_DriveFileLabels();
$label->setRestricted(true);
$file->setLabels($label);