0
我最近将Google Drive的API集成到我在CodeIgniter上构建的网站上。该网站是关于写一篇文章,并将其转换为Word文档,我已经设法使用提供的API脚本上传到Google Drive中无法预览/打开上传到Google文档API的文档
但是,我无法在Google上预览或打开上传的文档驾驶。但是,从Google驱动器下载文档并通过Microsoft Word处理器打开后,我可以查看和编辑它,请通知我应该如何使用Google文档工具在Google驱动器上编辑我的文档。
这里是我用来上传从网站生成的文档的代码,这里是附加的示例文档。
请注意:正如我前面提到的,当我将从Google下载的文档重新上传到Google驱动器时,文档运行良好,我可以预览并编辑它。
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $client->getAccessToken()) {
// We'll setup an empty 1MB file to upload.
$doc_file = $this->session->userdata('google_doc_file');
DEFINE("TESTFILE", __DIR__ . '/../../../papers/'.$doc_file.'.docx');
// This is uploading a file directly, with no metadata associated.
$file = new Google_Service_Drive_DriveFile();
$file->setName($doc_file.'.docx');
$result = $service->files->create(
$file,
array(
'data' => file_get_contents(TESTFILE),
'mimeType' => 'text/docx',
'uploadType' => 'multipart'
)
);
}