Package org.apache.tika.mime

Examples of org.apache.tika.mime.MimeTypes


  private static final Logger LOG = LoggerFactory.getLogger(MimeUtil.class.getName());

  public MimeUtil(Configuration conf) {
    tika = new Tika();
    ObjectCache objectCache = ObjectCache.get(conf);
    MimeTypes mimeTypez = (MimeTypes) objectCache.getObject(MimeTypes.class
        .getName());
    if (mimeTypez == null) {
      try {
          String customMimeTypeFile = conf.get("mime.types.file");
          if (customMimeTypeFile!=null && customMimeTypeFile.equals("")==false){
View Full Code Here


          InputStream in = new ByteArrayInputStream(mimeTypesString.getBytes("UTF-8"));
          inputStreams.add(in);
        }
       
        if (inputStreams.size() > 0) {
          MimeTypes mimeTypes = MimeTypesFactory.create(inputStreams.toArray(new InputStream[inputStreams.size()]));
          ServiceLoader loader = new ServiceLoader();
          this.detector = new DefaultDetector(mimeTypes, loader);
        } else {
          throw new MorphlineCompilationException("Missing specification for MIME type mappings", config);
        }     
View Full Code Here

          InputStream in = new ByteArrayInputStream(mimeTypesString.getBytes("UTF-8"));
          inputStreams.add(in);
        }
       
        if (inputStreams.size() > 0) {
          MimeTypes mimeTypes = MimeTypesFactory.create(inputStreams.toArray(new InputStream[inputStreams.size()]));
          ServiceLoader loader = new ServiceLoader();
          this.detector = new DefaultDetector(mimeTypes, loader);
        } else {
          throw new MorphlineCompilationException("Missing specification for MIME type mappings", config);
        }     
View Full Code Here

     * @param type valid mime-type
     * @return extension if it's known for specified mime-type, or empty string
     * otherwise
     */
    public static String getExtensionByMimeType(String type) {
        MimeTypes types = getDefaultMimeTypes();
        try {
            return types.forName(type).getExtension();
        } catch (Exception e) {
            LOGGER.warn("Can't detect extension for MIME-type " + type, e);
            return "";
        }
    }
View Full Code Here

  private static final Logger LOG = LoggerFactory.getLogger(MimeUtil.class.getName());

  public MimeUtil(Configuration conf) {
    tika = new Tika();
    ObjectCache objectCache = ObjectCache.get(conf);
    MimeTypes mimeTypez = (MimeTypes) objectCache.getObject(MimeTypes.class
        .getName());
    if (mimeTypez == null) {
      try {
          String customMimeTypeFile = conf.get("mime.types.file");
          if (customMimeTypeFile!=null && customMimeTypeFile.equals("")==false){
View Full Code Here

        TikaConfig config = getConfig();
        if (cType == null) {
            Detector detector = config.getDetector();
            try {
                MediaType mediaType = detector.detect(is, metadata);
                MimeTypes types = config.getMimeRepository();
                MimeType mime = types.forName(mediaType.toString());
                metadata.set(Metadata.CONTENT_TYPE, mediaType.getSubtype());
                return mime.getExtension();
            } catch (IOException e) {
                //swallow
            } catch (MimeTypeException e) {
View Full Code Here

TOP

Related Classes of org.apache.tika.mime.MimeTypes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.