Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
issue opening word doc using getInputStream
chau_interwoven
From a jsp page of a remote web application, I am attempting to download a word document from teamsite. I am able to open the document, and it appropriately opens within Word. However, the text of the document is jumbled with lots of strange characters. Any help on why the text within the word document is not displaying properly would be greatly appreciated!
Thanks! Chau
I based my code on the sample code in the ContentServices for Teamsite Cookbook (cssdk 2.1, ts 6.1). Here is my code:
CSClient client = (CSClient) session.getAttribute("client");
String path = request.getParameter( "path" );
String fname = request.getParameter("fname");
CSVPath vpath = new CSVPath(path + "/" + fname);
CSSimpleFile f = (CSSimpleFile) client.getFile(vpath);
int filesize = (int) f.getSize();
byte[] data = new byte[filesize];
DataInputStream in = new DataInputStream(f.getInputStream(true));
in.readFully(data);
in.close();
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename=" + fname);
OutputStream os = response.getOutputStream();
os.flush();
os.write(data);
os.close();
(I tried setting contentType equals to "application/ms-word" as well with no luck.)
Find more posts tagged with
Comments
chau_interwoven
To fix the problem, I had to call response.resetBuffer() before setting the content type and header.