【问题标题】:Not able to Downloading Files using Google Drive API V3无法使用 Google Drive API V3 下载文件
【发布时间】:2021-07-15 15:22:45
【问题描述】:

我面临问题“调用字符串上的成员函数 getBody()” 我正在使用以下代码

 public  function downloadFile($fileId , $name)
{
  try
  {
       $content = $this->service->files->get($fileId, array("alt" => "media"));
       $outHandle = fopen(APPPATH ."Downloads". "/" . $name , "w+");
       while (!$content->getBody()->eof()) {
            fwrite($outHandle, $content->getBody()->read(1024));
      }
       fclose($outHandle);
        return $outHandle;
    } catch (\Exception $e) {
  }

}

【问题讨论】:

    标签: php codeigniter google-api google-drive-api google-api-php-client


    【解决方案1】:

    这个选项可能会简单一些。

    $file = $service->files->get($fileId, array('alt' => 'media'));
    file_put_contents($file->name, $file->getBody());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-03
      • 2020-05-23
      • 2023-02-06
      • 1970-01-01
      • 2015-05-30
      • 1970-01-01
      相关资源
      最近更新 更多