Google docs 3.0 java API上传文件无法正常工作

问题描述:

我刚刚下载了newsest doc list api,并尝试一下。下面我的代码:Google docs 3.0 java API上传文件无法正常工作

DocsService client = new DocsService("testappv3"); 
client.setUserCredentials("username", "password"); 
File file = new File("c:/test.txt"); 
URL url = new URL("https://docs.google.com/feeds/defaults/private/full/"); 
String mimeType = DocumentListEntry.MediaType.fromFileName(file.getName()).getMimeType(); 
DocumentEntry newDocument = new DocumentEntry(); 
newDocument.setTitle(new PlainTextConstruct("test")); 
//newDocument.setMediaSource(new MediaFileSource(file, mimeType)); 
newDocument.setFile(file, mimeType); 
newDocument = client.insert(url, newDocument); 

误差低于:

com.google.gdata.util.ResourceNotFoundException: Not Found 
<HTML> 
<HEAD> 
<TITLE>Not Found</TITLE> 
</HEAD> 
<BODY BGCOLOR="#FFFFFF" TEXT="#000000"> 
<H1>Not Found</H1> 
<H2>Error 404</H2> 
</BODY> 
</HTML> 

你的URI是不正确的:

https://docs.google.com/feeds/defaults/private/full/ 

应该

https://docs.google.com/feeds/default/private/full/ 

(无S)

+0

好,它的工作原理,但如果我添加'newDocument.setTitle(new PlainTextConstruct(“test”));'会得到一个错误'com.google.gdata.util.ServiceException:发生未知错误。 的GDataServiceException已发生未知的错误 internalReason>'。这是否意味着我不能为我的文档提供一个新名称? – user1335794 2012-04-27 08:04:47

+0

您应该为此询问一个新问题。 – 2012-04-27 17:04:13