String.format(FILE_FORMAT, params.get(IMAGE_FILE), params.get(TYPE)));
String fileType = PathUtilities.extractType(file.getAbsolutePath());
if (file.exists()) {
RackResponse rackResponse = null;
try {
rackResponse = context.getRackResponse().withBody(file).withContentLength(file.length());
if (configuration != null) {
Map<String, String> customMimeTypes = (Map<String, String>) configuration.get(CONFIG_ELEMENT_MIME_TYPES);
if (!CollectionUtils.isEmpty(customMimeTypes) && customMimeTypes.containsKey(fileType)) {
rackResponse.withContentType(customMimeTypes.get(fileType));
} else {
rackResponse.withContentType(Mime.mimeType(fileType));
}
} else {
rackResponse.withContentType(Mime.mimeType(fileType));
}
} catch (FileNotFoundException e) {
throw new ControllerException("File not found: " + file.getAbsolutePath(), e);
}