I am using googledocs api to upload word, text and pdf files to google
docs. The format of the files after upload is messed up. I am only
able to upload plain text file with out any issues.

Is there a specific character encoding i need to use or set the
content type ?

servlet calling google docs api service:

FileItemIterator iterator = upload.getItemIterator(request);
  while (iterator.hasNext()) {
 FileItemStream item = iterator.next();
 if (!item.isFormField()) {
   String tm = item.getFieldName();
  InputStream is = item.openStream();
  String fileName = item.getName();

 ByteArrayOutputStream out = new ByteArrayOutputStream();
  int len;
  byte[] buffer = new byte[8192];

 while ((len = is.read(buffer, 0, buffer.length)) != -1)
  {
   out.write(buffer, 0, len);
  }
 String fileoutput = IOUtils.toString(out.toByteArray());
  createTempObject(fileName,fileoutput);

}
  }

google docs api service:
 public void createTempObject(String title, String content) throws
IOException,
      MalformedURLException, ServiceException, DocumentListException {

    DocumentListEntry newEntry = new DocumentEntry();
   MediaByteArraySource source = new
MediaByteArraySource(content.getBytes(), "text/html");
   newEntry.setTitle(new HtmlTextConstruct(title));
    newEntry.setMediaSource(source);
    service.setReadTimeout(MAX_TIMEOUT);
    service.setConnectTimeout(MAX_TIMEOUT);
    service.insert(buildUrl(URL_DEFAULT + URL_DOCLIST_FEED),
newEntry);
   }

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to