AnsweredAssumed Answered

Can't download .docx

Question asked by mangar on Aug 3, 2010
Latest reply on Aug 24, 2010 by mangar
When I download a docx file, it downloads fine, but when it opens up in Word, it says "file corrupted" I of course click through and Word recovers the document just fine. But I have some VERY upset managers who don't like Alfresco corrupting their documents. It's not of course, because if I go into Alfresco and click on download file, it works fine, no corruption. It only happens with a web service, and It only happens with docx.

I have a simple web service that downloads a document. I give it the uuid, and I get an InputStream like this:

ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
Reference contentReference = new Reference(storeRef,uuid,null);
readResult = contentService.read(new Predicate(new Reference[]{contentReference}, storeRef, null), Constants.PROP_CONTENT);
is = ContentUtils.getContentAsInputStream(readResult[0]);
return is;

in my jsp, I simply send it to the response like this:

AlfrescoBridge bridge = new AlfrescoBridge();  // my handy class
InputStream in = bridge.getFileInputStream(uuid);  // method above
response.reset();
response.setHeader ("Content-Disposition", "attachment;filename=\""+fileName+"\"");
ServletOutputStream sosStream = response.getOutputStream();
int ibit = 256;
while ((ibit) >= 0)   {
     ibit = in.read();
     sosStream.write(ibit);
}
sosStream.flush();
sosStream.close();
in.close();

I am using Alfresco 3.3g
I have upgraded my OpenOffice to 3.2.1

I suspect   ContentUtils.getContentAsInputStream(readResult[0]);

Please help, as my butt, and the future of Alfresco here is on the line.

Outcomes