Google docs api -- 上传 XML 文档
我正在尝试使用 google docs api 上传 xml 文档。但我得到了非法参数异常的例外情况
上传文档的代码是
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);
我得到的例外是
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 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有更好的方法在此处上传任何文档 http://code .google.com/a/eclipselabs.org/p/googledocs-rse/ 速度很快。如果有人还有其他东西,请在这里发布。
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.
在下面的代码中,mime类型字符串是错误的。
请按如下方式更改并尝试。
但 Google Documents List API 文档并没有说明您可以上传“xml”文件。
At the following codes, mime type string is wrong.
Please change as follows and try.
But Google Documents List API document does not say that you can uploaded "xml" file.