Php Can';更新谷歌驱动器文件

Php Can';更新谷歌驱动器文件,php,google-drive-api,Php,Google Drive Api,我正在尝试使用v3Google Drive SDK将文件上载到Google Drive: $this->drive() ->files ->update( $this->report->getId(), $this->report, // This is a Google_Service_Drive_DriveFile instance [ 'uploadType' =&

我正在尝试使用v3Google Drive SDK将文件上载到Google Drive:

$this->drive()
    ->files
    ->update(
        $this->report->getId(),
        $this->report,  // This is a Google_Service_Drive_DriveFile instance
        [
            'uploadType' => 'multipart',
            'data' => file_get_contents($this->getLocalReportLocation())
        ]
    );
我收到以下例外情况:

调用修补程序时出错:(403)资源主体包含不可直接写入的字段


显然,问题是由我通过以下方式获得的
$this->report
引起的:

// Fetch the latest synchronized report
$latestReport = $this->drive()
    ->files
    ->listFiles([
        'orderBy' => 'modifiedTime',
        'q'       => '\''.$this->userEmail.'\' in owners AND name contains \'AppName\'',
    ])
    ->getFiles()[0];

$this->report = $this->drive()
    ->files
    ->get($latestReport->id);
可能是
$this->report
,它是
\Google\u Service\u Drive\u DriveFile
的一个实例,在设置并传递给
update()
方法时,包含一些导致问题的字段

我通过将
\Google\u Service\u Drive\u DriveFile
的新实例传递到
update()
方法解决了这个问题,如下所示:

$this->drive()
    ->files
    ->update($this->report->getId(), (new \Google_Service_Drive_DriveFile()), [
        'uploadType' => 'multipart',
        'data' => file_get_contents($this->getLocalReportLocation()),
        'mimeType' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    ]);

如果只删除
数据
额外参数会怎么样?同样的问题,所以我猜不是
数据
参数引起的。将编辑问题。另外,更新方法的签名是什么?
公共函数更新($fileId,Google\u Service\u Drive\u DriveFile$postBody,$optrams=array())