将上传的文件转换为Google文档格式 [英] Convert uploaded file to Google Documents format
问题描述
我试图上传文件到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,
));
文件已正确上传,但没有任何转换,为什么?
您说得对,适当的mime类型Google Drive API接受的是 application / msword
。我发现在写这篇文章时,由于某些原因,Google Drive API不支持Word .docx格式转换。因此,请确保您的扩展程序不仅位于.bc文件中。 doc格式,但实际的文档内容也是旧的.doc(Word 97 - 2004)格式。
I'm trying to upload files to Google Drive but with the attribute convert=true
to allow a automatic conversion of upload file to Google Docs format...but it does not work:
$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,
));
The file is properly uploaded but without any conversion, why?
You are correct, that the proper mime type Google Drive API accepts is application/msword
. I also found out as of writing this, Google Drive API does not support Word .docx format conversion for some reason.
So make sure that not only your extension is in .doc format, but actual document content is also older .doc (Word 97 - 2004) format.
这篇关于将上传的文件转换为Google文档格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!