是否有任何方法来垃圾使用谷歌驱动器api v3 PHP文件?



我正在寻找一种方法来删除文件,而不必使用PHP API v3从谷歌驱动器永久丢失它们…我的意思是,我想把它扔掉。

查看V2参考,我注意到有一个直接的函数可以做到这一点,但在V3中它不再存在,它不起作用。

/**
* Move a file to the trash.
*
* @param Google_Service_Drive $service Drive API service instance.
* @param String $fileId ID of the file to trash.
* @return Google_Servie_Drive_DriveFile The updated file. NULL is returned if
*     an API error occurred.
*/
function trashFile($service, $fileId) {
try {
return $service->files->trash($fileId);
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
}
return NULL;
} 

所以,有没有一种方法与Google Drive PHP API V3垃圾到不会永久丢失的文件和/或文件夹?

我相信你的目标和你的现状如下。

  • 你想要移动的文件和文件夹到垃圾箱使用驱动器API v3与googleapi for PHP。
  • 您已经能够使用驱动器API v3,您的$service可以用于将文件移动到垃圾箱。

在本例中,"Files: update"驱动器API v3版本。示例脚本如下:

示例脚本:

$fileId = '###';  // Please set the file ID and folder ID.
$metadata = new Google_Service_Drive_DriveFile();
$metadata->setTrashed(true);
$res = $service->files->update($fileId, $metadata);
参考:

  • 文件:更新

相关内容

最新更新