Reputation: 1092
I need upload a image into Google doc with google format in order to retrieving it back and saving the storage uasage as well. Below it my code sample, it was work fine but broken recently, What I got just a empty document. Could anyone help me?
DocsService client = new DocsService("testappv1");
client.setUserCredentials(username, password);
client.setProtocolVersion(DocsService.Versions.V2);
File file = new File("C:/test.jpg");
DocumentEntry newDocument = new DocumentEntry();
newDocument.setTitle(new PlainTextConstruct("test"));
String mimeType = DocumentListEntry.MediaType.fromFileName(file.getName()).getMimeType();
newDocument.setMediaSource(new MediaFileSource(file, mimeType));
newDocument = client.insert(destFolderUrl, newDocument);
Upvotes: 0
Views: 213