gpt4 book ai didi

php - 如何读取上传到 Google Drive 的 PDF 文件的内容?

转载 作者:行者123 更新时间:2023-12-04 17:35:38 24 4
gpt4 key购买 nike

我想阅读上传到谷歌驱动器的 PDF 文件的内容。内容应该是人类可读的格式,而不是二进制格式。现在我正在使用谷歌驱动器 API 来读取内容,但无法做到这一点。

 $fileId = $request['thesis_google_id'];
$response = $service->files->get($fileId, array(
'alt' => 'media'));
$content = $response->getBody()->read(2024);

最佳答案

Google Drive API的核心功能是在 Google Drive 中下载和上传文件。这个 API 不能让你阅读任何东西,它只是为你存储文件并允许你下载它们。

Google Docs api确实可以让您访问读写文件,但我怀疑它只支持 google docs 格式的文件,而不支持 PDF。

您需要在本地下载该文件,然后使用某种形式的 PHP 阅读器来阅读它。

关于php - 如何读取上传到 Google Drive 的 PDF 文件的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56770648/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com