Java – how do I detect if the MIME type is an executable?

I am using Apache Tika to detect the MIME type of the input stream

http://www.file-extensions.org/filetype/extension/name/program-executable-files

I want to know the best way to cover them up Please give me some advice. Thank you

Solution

Apache Tika's MIME type has a hierarchy Therefore, instead of checking all possible executable types, you need to check whether the detected type has a parent, which is one of the few executable types

For windows, the main is application / x-msdownload You may also want to check the application / x-ms-installer

For UNIX, the main is application / x-elf, but you may also want to check the script format, such as application / x-sh, text / x-perl, text / x-python, etc

As for how to transfer from mimeType in Tika to its parent, you need this existing answer here – "correct use of Apache Tika mediatype" (note that if there are multiple levels between the detected MIME type and the basic executable parent type, recursion is required)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>