You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jarod <Fe...@haufe-lexware.com> on 2015/05/05 15:01:28 UTC

Content-Disposition error when downloading xlsx - UNIX

I am using apache-poi and poi-ooxml together with camel to create and http
transfer an xlsx file. 
I create the file using XSSFWorkbook. When testing locally (running a main
which start the routes) or when I deploy to the local tomcat7 everything is
working fine, the download of the xlsx is done and the file is readable.

When I deploy it to a Unix server and download the file, I receive an error
when I try to open it.
The error is "Excel found unreadable content in 'Filename.xlsx'. Do you want
to recover the contents of this workbook? If you trust the source of this
workbook, click Yes." After I click yes follow up error shows:
"Excel cannot open the file 'Filename.xlsx' because the file format or file
extension is not valid. Verify that the file has not been corrupted and that
the file extension matches the format of the file."

My code where I create the settings for the content:

XSSFWorkbook xlsx = writeToExcel(list);
ByteArrayOutputStream bos = getByteFormat(exchange, xlsx);
exchange.getIn().setHeader("Content-Disposition","attachment;
filename=ProductExports.xls");
exchange.getIn().setHeader(Exchange.CONTENT_TYPE,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
exchange.getIn().setHeader(Exchange.CONTENT_LENGTH,bos.size());

This code is done inside a Processor, that is why is set the content setting
is the header of the exchange.getIn().


Anyone encountered similar problem? or have any idea why is this happening? 

Thanks, 
jarod



--
View this message in context: http://camel.465427.n5.nabble.com/Content-Disposition-error-when-downloading-xlsx-UNIX-tp5766709.html
Sent from the Camel - Users mailing list archive at Nabble.com.