将上传的文件转换为Google文档格式

时间:2015-07-25 20:26:48

标签: php google-drive-api

我尝试将文件上传到Google云端硬盘但使用属性convert=true以允许自动将上传文件转换为Google文档格式...但它不起作用:

$drive_service = new Google_Service_Drive($client);
$file = new Google_Service_Drive_DriveFile();
$file->setTitle("Informe-imaxbd-alfa");
$result = $drive_service->files->insert($file, array(
'data' => file_get_contents("notas-gdrive.docx"),
'mimeType' => 'application/octet-stream',
'uploadType' => 'multipart',
'convert' => FALSE,
));

文件已正确上传但没有任何转化,为什么?

1 个答案:

答案 0 :(得分:0)

你是对的,Google Drive API接受的正确mime类型是application/msword。我在撰写本文时也发现,Google Drive API由于某种原因不支持Word .docx格式转换。

因此,请确保您的扩展程序不仅是.doc格式,而且实际文档内容也是旧的.doc(Word 97 - 2004)格式。