Hi,

I am trying to stream an image to the response and setting the proper mime
type to it prior to writing the stream to the output.

The file exists and is written but the mime type of the response is not set
according to what I expect it to be ("image/png"). Any idea?


WebResponse response = (WebResponse)getRequestCycle().getResponse();

*if* (imagePath != *null*) {

*try* {

File imageFile = *new* File(imagePath);

FileInputStream inputStream = *new* FileInputStream(imageFile);

response.setContentType(*DEFAULT_MIME_TYPE*);

Streams.*copy*(inputStream, response.getOutputStream());

*return*;

}

*catch* (FileNotFoundException e) {

}

*catch* (IOException e) {

}

}

// 404

response.getHttpServletResponse().setStatus(*NOT_FOUND*);

Reply via email to