Hi everybody,

I'm using this code to send a data stream to the client:

ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(new IResourceStream() {
[...]
    @Override
    public String getContentType() {
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    }
[...]
}, "data.xlsx");
component.getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);

The content type is completely ignored. It comes out as text/plain. It works with xml Content-Type+filename but I believe only because the filename pattern .xml results in application/xml content type being generated in ResourceStreamResource.newResourceResponse(Attributes attributes) which calls Application.getMimeType(String fileName):

            final String contentType;
            if (fileName != null && Application.exists())
            {
                contentType = *Application.get().getMimeType(fileName);*
            }
            else
            {
                contentType = stream.getContentType();
            }


The javadoc for IResourceStream.getContentType()**says "Return null to let ResourceStreamRequestHandler handle the Content-Type automatically".

Am I missing something? Shouldn't ResourceStreamResource.newResourceResponse(Attributes attributes) check for null value returned from stream.getContentType() before calling Application.getMimeType()?

Thank you very much,
Sebastian

Reply via email to