19 package org.sleuthkit.autopsy.modules.filetypeid;
21 import java.util.SortedSet;
22 import org.apache.tika.Tika;
23 import org.apache.tika.mime.MediaType;
24 import org.apache.tika.mime.MimeTypes;
38 private static final Tika
tikaInst =
new Tika();
53 String mimeType =
detect(abstractFile);
54 if (mimeType != null) {
76 int len = abstractFile.
read(buffer, 0, BUFFER_SIZE);
77 if (len < BUFFER_SIZE) {
79 System.arraycopy(buffer, 0, buf, 0, len);
84 String mimetype = tikaInst.detect(buf, abstractFile.
getName());
86 return mimetype.replace(
"tika-",
"");
87 }
catch (Exception ex) {
106 SortedSet<MediaType> m = MimeTypes.getDefaultMimeTypes().getMediaTypeRegistry().getTypes();
107 String[] split = mimeType.split(
"/");
109 if (split.length == 2) {
110 String type = split[0];
111 String subtype = split[1];
112 MediaType mediaType =
new MediaType(type, subtype);
113 ret = m.contains(mediaType);
static final Tika tikaInst
void addAttribute(BlackboardAttribute attr)
synchronized String detectAndSave(AbstractFile abstractFile)
boolean isMimeTypeDetectable(String mimeType)
final int read(byte[] buf, long offset, long len)
synchronized String detect(AbstractFile abstractFile)