1

I have a problem trying to update a Google document containing an image. In the first revision, the image will load as expected. But after updating it with the same HTML code I keep getting a spinner instead of the image.

I am using the Ruby gem created by Google (https://github.com/google/google-api-ruby-client).

Here is my test code:

# Setting up the client instance

require "google/api_client"
require "tempfile"

client = Google::APIClient.new
client.authorization.client_id = "<CLIENTID>"
client.authorization.client_secret = "<CLIENTSECRET>"
client.authorization.redirect_uri = "<REDIRECTURI>"
client.authorization.scope = "https://www.googleapis.com/auth/drive"
client.authorization.access_token = "<ACCESSTOKEN>"
client.authorization.refresh_token = "<REFRESHTOKEN>"
drive = client.discovered_api("drive", "v2")

# Creating the document (IMAGE DISPLAYED CORRECTLY)

file = drive.files.insert.request_schema.new({"title" => "Test document", "mimeType" => "text/html"})
temp = Tempfile.new "temp.html"
temp.write "<h1>Testing!</h1><p>Lorem ipsum.</p><img width='400px' src='http://www.digitaleconomics.nl/wp-content/uploads/2013/04/see-how-your-google-results-measure-up-with-google-grader-video-6b8bbb4b41.jpg'>"
temp.rewind
media = Google::APIClient::UploadIO.new(temp, "text/html")
result = client.execute(:api_method => drive.files.insert, :body_object => file, :media => media, :parameters => {"uploadType" => "multipart", "convert" => true})
temp.close

# Updating the document (GETTING SPINNER INSTEAD OF IMAGE)

file = client.execute(:api_method => drive.files.get, :parameters => {"fileId" => result.data.to_hash["id"]}).data
file.title = "Updated test document"
temp = Tempfile.new "temp.html"
temp.write "<h1>Testing!</h1><p>Lorem ipsum.</p><img width='400px' src='http://www.digitaleconomics.nl/wp-content/uploads/2013/04/see-how-your-google-results-measure-up-with-google-grader-video-6b8bbb4b41.jpg'>"
temp.rewind
media = Google::APIClient::UploadIO.new(temp, "text/html")
result = client.execute(:api_method => drive.files.update, :body_object => file, :media => media, :parameters => {"uploadType" => "multipart", "convert" => true, "fileId" => result.data.to_hash["id"], "newRevision" => false})
temp.close

Also, setting newRevision to false does not prevent a new revision from being created.

Can anyone help me out?

Paul Engel
  • 73
  • 1
  • 7
  • Docs files always creates new revisions. Since we don't meter Docs files and use user's quota for them, it shouldn't be a problem. Spinning sounds looks like a bug, we're investigating. – Burcu Dogan Jun 10 '13 at 14:19
  • Hi, Burcu. Did you have time to investigate this bug? – Paul Engel Jun 18 '13 at 15:11
  • This bug was also reported here: http://stackoverflow.com/questions/12740610 – jjw Sep 10 '13 at 00:15
  • Can you have a look a http://stackoverflow.com/questions/19224410/images-disappear-after-uploading-a-doc-with-conversion? This seems to be a similar problem. – Chris Obdam Oct 10 '13 at 08:56

0 Answers0