Search code examples
javagoogle-docsgoogle-docs-api

Google docs api -- Uploading a XML doc


I am trying to upload an xml doc using the google docs api. But I get the exception of Illegal Argument Exception

The code to upload the doc is

        File file = new File("/Users/Sana/Downloads/Sana_Upload_test.xml");
        DocumentEntry newDocument = new DocumentEntry();
        newDocument.setFile(file, "xml");
        newDocument.setTitle(new PlainTextConstruct("Sana.xml"));
        client.insert(new URL("https://docs.google.com/feeds/default/private/full/"), newDocument);

The exception that I get is

Exception in thread "main" java.lang.IllegalArgumentException: Invalid media type:xml
    at com.google.gdata.util.ContentType.<init>(ContentType.java:323)
    at com.google.gdata.data.docs.DocumentListEntry.setFile(DocumentListEntry.java:298)
    at Documents.main(Documents.java:74)

I know that upload of any type of document is only available for premier accounts, but my question is to find out if there is any work around for this issue?

Thanks, Sana.


Solution

  • I have a better way to upload any doc in here http://code.google.com/a/eclipselabs.org/p/googledocs-rse/ which is quick. If anyone has something else, please post it here.