List of usage examples for javax.activation MimetypesFileTypeMap MimetypesFileTypeMap
public MimetypesFileTypeMap(InputStream is)
From source file:com.qwazr.webapps.transaction.StaticManager.java
private StaticManager(File dataDir) { this.dataDir = dataDir; mimeTypeMap = new MimetypesFileTypeMap(getClass().getResourceAsStream("/com/qwazr/webapps/mime.types")); }
From source file:org.sakaiproject.tool.assessment.ui.servlet.InitMimeTypes.java
public void init(ServletConfig config) throws ServletException { super.init(config); String path = config.getServletContext().getRealPath("/WEB-INF/mime.types"); log.debug("**** mimetypes path=" + path); MimetypesFileTypeMap mimeTypeMap = null; FileInputStream input = null; try {//from w ww. j a v a2s . c o m input = new FileInputStream(path); log.debug("**** input=" + input); mimeTypeMap = new MimetypesFileTypeMap(input); log.debug("**** mimeTypeMap=" + mimeTypeMap); MimeTypesLocator.setMimetypesFileTypeMap(mimeTypeMap); } catch (Exception ex) { log.warn(ex.getMessage()); } finally { try { if (input != null) input.close(); } catch (IOException ex1) { log.warn(ex1.getMessage()); } } }
From source file:de.u808.simpleinquest.service.impl.DefaultMimeTypeRegistry.java
public void afterPropertiesSet() throws Exception { try {//from w w w. j ava2 s . c om if (!this.customMimeTypesConfigFile.exists()) { log.error("Cant create MimetypesFileTypeMap. Custom MimeType-File not found"); } else { mimetypesFileTypeMap = new MimetypesFileTypeMap( new FileInputStream(customMimeTypesConfigFile.getFile())); } } catch (FileNotFoundException e) { log.error("Cant create MimetypesFileTypeMap. Custom MimeType-File not found", e); } }
From source file:org.gluu.oxtrust.ldap.service.ImageRepository.java
public void initFileTypesMap() throws Exception { fileTypeMap = MimetypesFileTypeMap.getDefaultFileTypeMap(); InputStream is = ImageRepository.class.getClassLoader() .getResourceAsStream("META-INF/mimetypes-gluu.default"); try {// w ww . jav a 2s.c o m if (is != null) { fileTypeMap = new MimetypesFileTypeMap(is); } } catch (Exception ex) { log.error("Failed to load file types map. Using default one.", ex); fileTypeMap = new MimetypesFileTypeMap(); } finally { IOUtils.closeQuietly(is); } }
From source file:io.milton.s3.controller.AmazonS3Controller.java
@PutChild public File createFile(Folder parent, String newName, InputStream inputStream, Long contentLength, String contentType) {//from ww w . j a v a 2s . c o m LOG.info("Creating file " + inputStream.toString() + " with name " + newName + " in the folder " + parent.getName() + " in bucket " + BUCKET_NAME); // Create a file and store into Amazon Simple Storage Service File newFile = parent.addFile(newName); newFile.setSize(contentLength); // Get default content type if cannot get via milton if (StringUtils.isEmpty(contentType)) { contentType = new MimetypesFileTypeMap(inputStream).getContentType(newName); } newFile.setContentType(contentType); LOG.info("Successfully created file " + newName + " [name=" + newName + ", contentLength=" + contentLength + ", contentType=" + contentType + "] in bucket " + BUCKET_NAME); boolean isCreatedFile = amazonStorageService.putEntity(BUCKET_NAME, newFile, inputStream); if (!isCreatedFile) { LOG.error("Could not create file " + newName + " in bucket " + BUCKET_NAME); throw new RuntimeException("Could not create file " + newName + " in bucket " + BUCKET_NAME); } LOG.warn("Successfully created file " + newName + " under folder " + parent + " in bucket " + BUCKET_NAME); return newFile; }
From source file:com.aurel.track.attachment.AttachBL.java
/** * create the mime type-map// w w w . j a v a2 s . c o m * @param is, stream with fiel-based mime-definitions */ private static void createMimeTypeMap(InputStream is) { if (is != null) { mimeTypeMap = new MimetypesFileTypeMap(is); } else { mimeTypeMap = new MimetypesFileTypeMap(); } }