2012-04-26 6 views
-1

방금 ​​newsest doc list api를 다운로드하고 사용해 보았습니다. 아래 내 코드 :Google docs 3.0 자바 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> 

답변

1

귀하의 URI가 올바르지 않습니다

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

이이어야한다 (아무와 함께 사용)

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

+0

잘 작동하지만,이'newDocument.setTitle (new PlainTextConstruct ("test"));를 추가하면'com.google.gdata.util.ServiceException : 알 수없는 오류가 발생했습니다. GDataServiceException 알 수없는 오류가 발생했습니다.'. 이는 내 문서에 새로운 이름을 줄 수 없다는 뜻입니까? – user1335794

+0

아마도 새로운 질문을해야 할 것입니다. –

관련 문제