我正在尝试使用 Google Drive API 将 docx 文件导出为压缩的 html(另存为压缩的 html 是 google docs 的功能之一)。但根据文档,支持的导出 mime 类型是。 https://developers.google.com/drive/manage-downloads
文本/html
文本/普通
应用程序/rtf
应用程序/vnd.oasis.opendocument.text
申请/pdf
应用程序/vnd.openxmlformats-officedocument.wordprocessingml.document
上传代码
file = drive.files.insert.request_schema.new({
'title' => 'My document',
'description' => 'A test document',
'mimeType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
}
)
media = Google::APIClient::UploadIO.new('gdoc.docx', 'application/msword')
result = client.execute(
:api_method => drive.files.insert,
:body_object => file,
:media => media,
:parameters => {
'uploadType' => 'multipart',
'convert' => 'true'
}
)
下载代码
download_url = result.data.to_hash['exportLinks']['text/html']
html = client.execute(:uri => download_url)
谁能告诉我如何将谷歌文档导出为压缩的 html ?
最佳答案
我也有同样的问题。
显然 导出使用驱动 API 将 Google 文档转换为 mimeType="text/html"与单击同一文档的 不同。 “文件 > 下载为 > 网页(.html,压缩)”菜单项。
我想知道 Google Folks 能否解释一下这种不对称性。
关于ruby-on-rails - 使用 google drive API 将 docx 导出为压缩的 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17930075/