[Koha] How to check a file's MIME type in KOHA

Indranil Das Gupta indradg at gmail.com
Mon Jan 30 22:44:29 NZDT 2017


Hi Rajeesh,

On Mon, Jan 30, 2017 at 10:52 AM, Rejeesh K.Nair <rejeeshknair at gmail.com>
 wrote:


> I need to check the MIME type of each uploaded file for security purposes.
>
> Some search results from Google suggest that we can do it with the help of
> the File::MimeInfo <https://metacpan.org/pod/File::MimeInfo>Perl module.
>
> How can we install the File::MimeInfo module in KOHA and check the MIME
> types, or is there some better way?
>

IIRC, that sort of generic mimetype detection functionality does not exist
in Koha. From the top of my head, the only place where we actively check
for mimetype is the image upload option using GD which is basically
restricted to a few image formats like PNG, JPEG, XPM etc.

Short answer: To implement this on the server side, you have to write the
necessary code. As a stop gap, you *could* use the Javascript FileReader
object to check the mimetype on the client side. but that is not a fool
proof  solution.

hope this helps.
--
Indranil Das Gupta
L2C2 Technologies

Phone : +91-98300-20971
WWW  : http://www.l2c2.co.in
Blog    : http://blog.l2c2.co.in
IRC     : indradg on irc://irc.freenode.net
Twitter : indradg


More information about the Koha mailing list