Failed to upload image file to Google Doc via java api

below is my code

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); 

The document was created successfully, but it did not contain anything.

+1
source share
1 answer

try the following

 client.insert(new URL("https://docs.google.com/feeds/documents/private/full/?convert=false"), newDocument); 

I think the bit ?convert=false important, not sure how you do it without a URL

 client.insert(new URL(destFolderUrl+ "?convert=false"), newDocument); 

hope will work in your case

+3
source

All Articles