Export docx to zipped html using Google Drive API

I am trying to export a docx file to zipped html using the Google Drive API (Save as zipped html is one of the features of Google docs). But according to the documentation, export mime types are supported. https://developers.google.com/drive/manage-downloads

text / html

text / plain

Application / RTF

Application / vnd.oasis.opendocument.text

Appendix / PDF

Application / vnd.openxmlformats-officedocument.wordprocessingml.document

UPLOAD Code

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 code

 download_url = result.data.to_hash['exportLinks']['text/html'] html = client.execute(:uri => download_url) 

Can anyone tell me how can I export a google document in zipped html?

+4
source share
1 answer

I have the same problem.

Apparently, exporting a Google document to mimeType = "text / html" using the drive-API does not match clicking the same document "File> Download-as> Web Page (.html, zipped)" .

  • In the case of export, a file of 32 kilobytes in size is loaded on one html page.
  • In the file "File> Download-as> Webpage (.html, zipped)" .zip contains one file of 11k bytes
  • The content seems REALLY different.

I wonder if Google Folks can shed light on this asymmetry.

0
source

Source: https://habr.com/ru/post/1494101/


All Articles