use of org.openecard.control.binding.http.common.MimeType in project open-ecard by ecsec.
the class FileHandler method handleFile.
private void handleFile(Http11Response httpResponse, URL file) throws Exception {
String fileName = file.toString();
String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
MimeType mimeType = MimeType.fromFilenameExtension(fileExtension);
String typeName = (mimeType != null) ? mimeType.getMimeType() : MimeType.TEXT_PLAIN.getMimeType();
httpResponse.setStatusCode(HttpStatus.SC_OK);
BasicHttpEntity entity = new BasicHttpEntity();
entity.setContent(file.openStream());
entity.setContentType(ContentType.create(typeName, "UTF-8").toString());
httpResponse.setEntity(entity);
}
Aggregations