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();
54 public synchronized String
detectAndSave(AbstractFile abstractFile)
throws TskCoreException {
55 String mimeType =
detect(abstractFile);
56 if (mimeType != null) {
58 BlackboardArtifact getInfoArt = abstractFile.getGenInfoArtifact();
59 BlackboardAttribute batt =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_FILE_TYPE_SIG.getTypeID(),
FileTypeIdModuleFactory.getModuleName(), mimeType);
60 getInfoArt.addAttribute(batt);
76 public synchronized String
detect(AbstractFile abstractFile) {
79 int len = abstractFile.read(buffer, 0, BUFFER_SIZE);
80 if (len < BUFFER_SIZE) {
82 System.arraycopy(buffer, 0, buf, 0, len);
87 String mimetype = tikaInst.detect(buf, abstractFile.getName());
89 return mimetype.replace(
"tika-",
"");
90 }
catch (Exception ex) {
110 SortedSet<MediaType> m = MimeTypes.getDefaultMimeTypes().getMediaTypeRegistry().getTypes();
111 String[] split = mimeType.split(
"/");
113 if (split.length == 2) {
114 String type = split[0];
115 String subtype = split[1];
116 MediaType mediaType =
new MediaType(type, subtype);
117 ret = m.contains(mediaType);
static final Tika tikaInst
synchronized String detectAndSave(AbstractFile abstractFile)
boolean isMimeTypeDetectable(String mimeType)
synchronized String detect(AbstractFile abstractFile)