String mime = content.getProperty("jcr:mimeType").getString();
String encoding =
content.hasProperty("jcr:encoding") ? content.getProperty("jcr:encoding").getString() : DEFAULT_ENCODING;
MimeTypeResolver resolver = new MimeTypeResolver();
String fileName = file.getName();
String fileExt = "";
if (fileName.lastIndexOf(".") > -1)
{
fileExt = fileName.substring(fileName.lastIndexOf(".") + 1);
fileName = fileName.substring(0, fileName.lastIndexOf("."));
}
String mimeExt = resolver.getExtension(mime);
if (fileExt == null || fileExt.length() == 0)
{
fileExt = mimeExt;
}
response.setContentType(mime + "; charset=" + encoding);