I have a document (native Google doc) in Google Drive that I need to update from my Java app. What I did so far is to download the doc as html
String downloadUrl = doc.getExportLinks().get("text/html");
HttpResponse resp = service.getRequestFactory()
.buildGetRequest(new GenericUrl(downloadUrl))
.execute();
String contents = IOUtils.toString(resp.getContent());
Then I update the contents in the String object and send the update to Drive:
ByteArrayContent mediaContent = ByteArrayContent.fromString("text/html", contents);
service.files().update(doc.getId(), doc, mediaContent).execute();
This works fine for very simple documents. But if the document contains an image, it disappears. The src attribute of the img tag is empty.
Does Google provide some other methods of updating the contents of a Google Document? Is there an API similar to the Google Spreadsheet API?