Hi All, I have checked the MIME information of a specific file using its extension. But actually I need details of exact file. Say, I have a file like test.jpg , somebody renamed its extension as test.pdf. If we checked the MIME information of test.pdf, it should display the output as image/jpeg. For implementing this , I am trying to integrate *File::MMagic::XS* into KOHA with the following steps. 1. Download *File::MMagic::XS* from http://search.cpan.org/~dmaki/ File-MMagic-XS-0.09008/lib/File/MMagic/XS.pm <http://search.cpan.org/%7Edmaki/File-MMagic-XS-0.09008/lib/File/MMagic/XS.pm> . 2. Extract the tar file and put the extracted file into usr/share/koha/lib/C4. 3. Take command prompt and Use command : cd /usr/share/koha/lib/C4/File- MMagic/ 4. Use command: perl Makefile.PL 5. Use command: make 6. Use command: make install After that , call *use C4::File-MMagic::lib::File::MMagic::XS;* *my $m = File::MMagic::XS->new();$m = File::MMagic::XS->new('/etc/magic'); # use external magic filemy $mime = $m->get_mime($source);* into the specific page and upload a jpeg file.But I got the MIME type as *text/plain* Can someone help on this issue? Regards, Rejeesh K.Nair
On Wed, Feb 1, 2017 at 2:51 PM, Indranil Das Gupta <indradg@gmail.com> wrote:
Hi,
You need to look into /usr/share/koha/lib/Koha/Upload.pm and /usr/share/koha/intranet/cgi-bin/tools/upload.pl files.
The perl module file is place where you need to write up the new function to handle the mimetype and then call that function from upload.pl script.
hope this helps -idg
-- Indranil Das Gupta L2C2 Technologies
Phone : +91-98300-20971 <098300%2020971> WWW : http://www.l2c2.co.in Blog : http://blog.l2c2.co.in IRC : indradg on irc://irc.freenode.net Twitter : indradg
On Tue, Jan 31, 2017 at 10:48 AM, Rejeesh K.Nair <rejeeshknair@gmail.com> wrote:
Hi Indranil,
Thank you for your quick reply.
Could you please help me, how to integrate the code to check the MIME type in KOHA?
Regards, Rejeesh K Nair
On Mon, Jan 30, 2017 at 3:14 PM, Indranil Das Gupta <indradg@gmail.com> wrote:
Hi Rajeesh,
On Mon, Jan 30, 2017 at 10:52 AM, Rejeesh K.Nair < rejeeshknair@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 <098300%2020971> WWW : http://www.l2c2.co.in Blog : http://blog.l2c2.co.in IRC : indradg on irc://irc.freenode.net Twitter : indradg
-- Thanks & Regards,
Rejeesh K.Nair m: +91 (0) 9495316906 <+91%2094953%2016906> e: rejeeshknair@gmail.com <https://www.facebook.com/rejeeshnairk> <https://twitter.com/rejeeshknair> <http://in.linkedin.com/in/rejeeshknair> <https://www.instagram.com/rejeeshknair/>
-- Thanks & Regards,
Rejeesh K.Nair m: +91 (0) 9495316906 <094953%2016906> e: rejeeshknair@gmail.com <https://www.facebook.com/rejeeshnairk> <https://twitter.com/rejeeshknair> <http://in.linkedin.com/in/rejeeshknair> <https://www.instagram.com/rejeeshknair/>
-- Thanks & Regards, Rejeesh K.Nair m: +91 (0) 9495316906 e: rejeeshknair@gmail.com <https://www.facebook.com/rejeeshnairk> <https://twitter.com/rejeeshknair> <http://in.linkedin.com/in/rejeeshknair> <https://www.instagram.com/rejeeshknair/>