无法更新Google云端硬盘文件

仙农酮

我正在尝试使用v3 Google 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())
        ]
    );

而且我收到以下异常:

调用PATCH https://www.googleapis.com/upload/drive/v3/files/ABCDe4FGHvXZTKVOSkVETjktNE0?uploadType=multipart时出错:(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_Service_Drive_DriveFile,其中包含一些字段,这些字段在设置并传递给update()方法时会引起问题

我能够通过将新实例传递\Google_Service_Drive_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'
    ]);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Google云端硬盘-无法同步的文件

来自分类Dev

无法使用可恢复方法更新Google云端硬盘中的文件

来自分类Dev

无法将文件上传到Google云端硬盘

来自分类Dev

无法将文字附加到Google云端硬盘文件中

来自分类Dev

无法自动永久删除Google云端硬盘上的文件

来自分类Dev

无法共享文件(通过Gmail或Google云端硬盘)

来自分类Dev

Google云端硬盘可以上传文件,但无法查看

来自分类Dev

从Google云端硬盘导入文件

来自分类Dev

Google云端硬盘桌面无法启动

来自分类Dev

如何从Google云端硬盘读取txt文件?

来自分类Dev

Google云端硬盘中文件的JSON列表

来自分类Dev

附加来自Google云端硬盘的文件

来自分类Dev

如何从Google云端硬盘删除文件

来自分类Dev

复制Google云端硬盘上的文件

来自分类Dev

从Google云端硬盘下载所选文件

来自分类Dev

无法将文件上传到Google云端硬盘中的文件夹

来自分类Dev

无法覆盖Google云端硬盘AppData文件夹中的文件INTERNAL_ERROR

来自分类Dev

无法使用Google App脚本上传到Google云端硬盘上的子文件夹

来自分类Dev

如何将持续更新的文件夹上传到Google云端硬盘?

来自分类Dev

无法使用API从Google云端硬盘下载文件-node.js

来自分类Dev

无法在Google云端硬盘文件夹中创建虚拟环境

来自分类Dev

无法从站点用户选择的Google云端硬盘下载(非公开)文件

来自分类Dev

通过终端使用Google云端硬盘时无法访问文件夹

来自分类Dev

Google云端硬盘无法将.ipynb文件识别为colab笔记本

来自分类Dev

Google云端硬盘同步时无法在Mac上保存Photoshop文件

来自分类Dev

无法在Google云端硬盘中使用Drivenotepad应用程序打开txt文件

来自分类Dev

无法访问刚刚创建的Google云端硬盘文件夹

来自分类Dev

无法使用Google云端硬盘API获取文件所有者

来自分类Dev

停用Google云端硬盘文件夹外部的Google云端硬盘上下文菜单

Related 相关文章

  1. 1

    Google云端硬盘-无法同步的文件

  2. 2

    无法使用可恢复方法更新Google云端硬盘中的文件

  3. 3

    无法将文件上传到Google云端硬盘

  4. 4

    无法将文字附加到Google云端硬盘文件中

  5. 5

    无法自动永久删除Google云端硬盘上的文件

  6. 6

    无法共享文件(通过Gmail或Google云端硬盘)

  7. 7

    Google云端硬盘可以上传文件,但无法查看

  8. 8

    从Google云端硬盘导入文件

  9. 9

    Google云端硬盘桌面无法启动

  10. 10

    如何从Google云端硬盘读取txt文件?

  11. 11

    Google云端硬盘中文件的JSON列表

  12. 12

    附加来自Google云端硬盘的文件

  13. 13

    如何从Google云端硬盘删除文件

  14. 14

    复制Google云端硬盘上的文件

  15. 15

    从Google云端硬盘下载所选文件

  16. 16

    无法将文件上传到Google云端硬盘中的文件夹

  17. 17

    无法覆盖Google云端硬盘AppData文件夹中的文件INTERNAL_ERROR

  18. 18

    无法使用Google App脚本上传到Google云端硬盘上的子文件夹

  19. 19

    如何将持续更新的文件夹上传到Google云端硬盘?

  20. 20

    无法使用API从Google云端硬盘下载文件-node.js

  21. 21

    无法在Google云端硬盘文件夹中创建虚拟环境

  22. 22

    无法从站点用户选择的Google云端硬盘下载(非公开)文件

  23. 23

    通过终端使用Google云端硬盘时无法访问文件夹

  24. 24

    Google云端硬盘无法将.ipynb文件识别为colab笔记本

  25. 25

    Google云端硬盘同步时无法在Mac上保存Photoshop文件

  26. 26

    无法在Google云端硬盘中使用Drivenotepad应用程序打开txt文件

  27. 27

    无法访问刚刚创建的Google云端硬盘文件夹

  28. 28

    无法使用Google云端硬盘API获取文件所有者

  29. 29

    停用Google云端硬盘文件夹外部的Google云端硬盘上下文菜单

热门标签

归档