안녕하세요. 안드로이드 google docs 연동하려 하는 사람입니다.
음... 문서파일을 create 하는 것 까지는 진행 하였지만
파일을 업로드 하려는 부분에서 막히네요...

다음은 Google Api문서에 있는 Multipart(Boundary는 END_OF_PART)를 이용하여 서버로 보내는 내용입니다.


POST /feeds/default/private/full
GData-Version: 3.0
Authorization: <your authorization header here>
Content-Length: 73612
Content-Type: multipart/related; boundary=END_OF_PART
Slug: test.doc
--END_OF_PART
Content-Type: application/atom+xml

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007"> 
 <category scheme="http://schemas.google.com/g/2005#kind"     
  term="http://schemas.google.com/docs/2007#document"/>
 <title>example document</title> 
 <docs:writersCanInvite value="false" />
</entry>

--END_OF_PART
Content-Type: application/msword

... doc contents here ...

--END_OF_PART--

저 역시 이와 동일하게 서버로 전송시킬 헤더와 Body부분의 metadata를 multipart에 셋팅하고 ByteArrayBuffer에
차례로 append 시켜 줬습니다.

... doc contents here ... 부분은 파일스트림을 byte화 하여 append 시켜줬습니다.
그런데 뭐가 문제인지 리턴코드로 400을 받습니다. 201을 리턴 받아야 파일 업로드가 정상적으로 실행된것인데
계속 400을 받는 이유를 모르겠네요.. 꼭 Google Docs뿐 아니라 캘린더나 피카사등 파일 업로드 해보신 분들의
의견을 듣고 싶어 이렇게 글 올립니다.
아래 코드 일부분 포함합니다.

private static final String FEED_URL = "https://docs.google.com/feeds/default/private/full";
...


 public void doUpload()
    {
     .....
     String url = FEED_URL;
     String filename = "byeongjoon.doc";
     HttpClient client = new DefaultHttpClient();
     HttpPost post = new HttpPost(url);
     
     .....
     
  try {
      File file = new File(path);//파일 불러온것도 확인...
      Multipart multipart = new Multipart("Media multipart posting", "END_OF_PART");
      meta_xml = "<?xml version='1.0' encoding='UTF-8'?> " +
        "<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:docs=\"http://schemas.google.com/docs/2007\">" +
        "<category scheme=\"http://schemas.google.com/g/2005#kind\"" +
        "term=\"http://schemas.google.com/docs/2007#document\"/>" +
        "<title>" + filename + "</title>" +
        "<docs:writersCanInvite value=\"false\"/>" +
          "</entry>";
      multipart.addPart(meta_xml, "application/atom+xml");//add 할때 Boundary(END_OF_PART)는 multipar에서 잡아줍니다.
      multipart.addPart(file, "application/msword");
      
      MultipartNotificationEntity entity = new MultipartNotificationEntity(multipart);
      HttpParams params = client.getParams();
      params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
      params.setParameter(CoreConnectionPNames.SO_TIMEOUT, new Integer(15000));
      params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, new Integer(15000));
      
   getAccountAuthToken();
   post.addHeader("GData-Version", "3.0");
      post.addHeader("Authorization", "GoogleLogin auth=" + token);//토큰 확인 했습니다.
      //post.addHeader("Content-Length", con_Len);//Length를 추가시키면 이상하게 Exception으로 넘어가네요...
      post.addHeader("Content-Type", "multipart/related; boundary=\"END_OF_PART\"");
      post.addHeader("Slug", "byeongjoon.doc");
      
      post.setEntity(entity);
      
      HttpResponse response = client.execute(post);
      StatusLine line = response.getStatusLine();
      
      int code = line.getStatusCode();
      Log.i(TAG, "code = " + code);//여기서 201을 리턴 받아야 하지만 400을 리턴받음...
   
     } catch (Exception e) {
      Log.i(TAG, "Exception");
     }
     
    }