【问题标题】:Convert uploaded file to Google Documents format将上传的文件转换为 Google 文档格式
【发布时间】:2015-07-25 20:26:48
【问题描述】:

我正在尝试将文件上传到 Google Drive,但使用属性 convert=true 允许将上传文件自动转换为 Google Docs 格式...但它不起作用:

$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,
));

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

【问题讨论】:

  • 对不起,我也尝试过 'convert'=>TRUE,
  • 问题与 'mimeType' 放置正确的 mimetype 相关(在本例中为 application/msword,现在转换工作正常。
  • mimetypes 的完整列表在:stackoverflow.com/questions/11894772/…

标签: php google-drive-api


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-06
    • 2014-06-18
    • 1970-01-01
    • 1970-01-01
    • 2018-01-07
    • 1970-01-01
    • 1970-01-01
    • 2022-01-04
    相关资源
    最近更新 更多