Vinod
Vinod

Reputation: 21

How to find the mime type of .bat file using Tika API?

I am using tika-core.jar to detect the mime type.

When I try to find the mime type of bat file, it is giving mime type as text/plain instead of application/x-bat.

Upvotes: 1

Views: 786

Answers (3)

JacquesLeRoux
JacquesLeRoux

Reputation: 611

Note: in the case of *.bat files, Tika (1.24.1) relies only on the .bat extension only, it does not parse the content. And just noticed that's not even alway true. It does not spot *.ps1 even with the extension. In both cases it returns text/plain

Upvotes: 0

Anish B.
Anish B.

Reputation: 16459

Tika is giving the correct output.

The jar used is tika-core-1.22.

The code is given below (what I have tried) :

public class Test {

    public static void main(String[] args) throws IOException {
        File batchFile = new File("C:/Users/Anish/Desktop/abc.bat");
        Tika tika = new Tika();
        System.out.println(tika.detect(batchFile));
    }

}

Screenshot of the output :

enter image description here

Upvotes: 3

Vinod
Vinod

Reputation: 21

still am getting text/plain for bat file. I don't understand why i am getting text/plain i did test the code in my local but am getting text/plain for bat file

Upvotes: 0

Related Questions