2011-03-08 9 views
0

Google 문서 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) 

나는 모든 종류의 문서의 업로드입니다 알고있다 얻을 예외입니다 업로드 불법 인수 예외

코드의 예외가 프리미어 계정에서만 사용할 수 있지만 내 질문은이 문제에 대한 해결 방법이 있는지 확인하는 것입니다.

감사합니다. 사나.

답변

0

다음 코드에서 MIME 유형 문자열이 잘못되었습니다.

newDocument.setFile(file, "xml"); 

다음과 같이 변경하십시오.

newDocument.setFile(file, "text/plain"); 

그러나 Google Documents List API document는 "XML"파일을 업로드 할 수있는 말을하지 않습니다.

+0

이것은 내 XML 파일을 원하지 않는 .doc 형식으로 변환합니다. – Sana

+0

예. 알아. Google App에 대한 최고의 계정이있는 경우 URL 옵션의 "? convert = false"를 사용하여 업로드 할 수 있습니다. 그러나 나는 그것을 시험해 볼 수 없다. –

+0

불행히도 최고의 계정이 없습니다. :-( – Sana

관련 문제