17

Something seems to have recently broken with the Google Docs conversion when using the documents list API. Updates made to existing document entries won't be converted into the Google Docs format correctly and images in the document will not appear.

Steps To Reproduce

  1. I have a .docx file that has a couple lines of text, and an image.

  2. Using the documents list API, I upload the file as a NEW entry (with conversion turned ON), and it works fine. I'm able to open the converted document in Google Docs and it looks fine.

  3. Next, using the documents like API, I upload the file again as an UPDATE to the original entry (with conversion turned on). Now when I open the converted document in Google Docs, the images are missing. There is a blank rectangle with a spinning busy indicator that appears where the images are supposed to be.

Additional Info

So the problem only happens when updating the existing entry. Files uploaded as brand new entries don't have this problem.

This must have broken within the last 24 hours or so...I have an existing app that was working fine, and now all the documents that it updates have their images missing. Did something get updated on the backend that caused this to break?

I've tested this with a variety of .docx and .doc files containing a variety of images.

PLEASE, HELP...this has been totally BROKEN for a week now. I'd just like to know if this is an issue that the engineers at Google are aware of and if someone is looking into it.

timiTao
  • 1,417
  • 3
  • 20
  • 34
KabukiAdam
  • 241
  • 2
  • 5
  • I managed to reproduce the issue and I filed an internal bug. I'll update this thread as soon as I have the results from the investigation – Claudio Cherubino Oct 12 '12 at 20:54
  • Any progress? This problem also occurs using the latest Drive SDK and when uploading other file formats. (I'm seeing it with .odt files.) – jjw Apr 23 '13 at 06:17

1 Answers1

0

(Oct 2020): It's 2020, and this question is really outdated. The Google Documents List API was deprecated in 2012 and shutdown in 2015, replaced by the Google Drive API.

The Drive API is able to import (upload & convert) a Word file whether creating or updating with images into Google Docs format without issue. Below is some pseudocode (Python) for both cases. The 1st uploads a Word file named person.docx which has an image. After it uploads, a message is displayed to the user, and you can verify the images are in the Google Doc.

DOCX_FILE = 'person.docx'
DOCS_MIME = 'application/vnd.google-apps.document'
    :
    : # credentials code for user acct auth (OAuth client ID) or service acct auth
    :
DRIVE = discovery.build('drive', 'v3', ...) # http= or creds= dep on auth type
body = {'name': DOCX_FILE, 'mimeType': DOCS_MIME}
res = DRIVE.files().create(media_body=DOCX_FILE, body=body,
        fields='name,mimeType').execute()
print('Uploaded "%s" (as %s)' % (res['name'], res['mimeType']))

As the OP mentions, creating a file works perfectly as before. If you edit an existing Doc, you need to provide its Drive file ID in addition to the file payload as before, and call files().update() instead of files().create(), and it works as well:

DRIVE_ID = 'YOUR_FILE_ID'. # existing file in Drive
DOCX_FILE = 'person.docx'  # Word file to replace the above file with
DOCS_MIME = 'application/vnd.google-apps.document'
    :
    : # credentials code as above
    :
DRIVE = discovery.build('drive', 'v3', ...) # same as above
body = {'name': DOCX_FILE, 'mimeType': DOCS_MIME}
res = DRIVE.files().update(fileId=DRIVE_ID, media_body=DOCX_FILE,
        body=body, fields='name,mimeType').execute()
print('Updated "%s" (as %s)' % (res['name'], res['mimeType']))

If you're new to the Drive API, read on. For manipulating documents that are already in Drive, specifically document-oriented operations, you'd use the Google Docs, Sheets, and Slides APIs, but to perform file-level access such as imports/exports, copy, move, rename, etc., use the Google Drive API instead. If you're new to the Drive API, here are some examples aside from the above:

(*) - TL;DR: upload plain text file to Drive, import/convert to Google Docs format, then export that Doc as PDF. Post above uses Drive API v2; this follow-up post describes migrating it to Drive API v3, and here's a developer video combining both "poor man's converter" posts.

To learn more about how to use Google APIs with Python in general, check out my blog as well as a variety of Google developer videos (series 1 and series 2) I've produced.

wescpy
  • 10,689
  • 3
  • 54
  • 53