Subject: | Replace File::MMagic |
From an IRC conversation that started this:
11:07 <fish> did you ever considered using something else than
File::MMagic in CGI-Application-Plugin-Stream? its now the second time
that i have issues with it on recognising the correct mime-types..
11:08 <fish> with 20 open tickets and the last release von januar 2006,
File::MMagic seems pretty dead..
11:12 <fish> i can write a small patch for CGI-Application-Plugin-Stream
to use mime::types instead. it seems to get updated more frequently and
i could use it to try to figure out the mime-type by content (like
mmagic) and additional a file-suffix-based fallback..
11:29 <fish> i don't use mod_perl, but mark stosberg says it should be
avoided: http://cpanratings.perl.org/dist/File-MMagic
11:30 <fish> eh, File::MMagic should be avoided because it has issues in
mod_perl env *clarify*
So I spent some time thinking about this and a sticking point is that
people can stream a filename or a filehandle. File::MMagic was nice
because you can feed it a filehandle. MIME::Types seems to handle
figuring out a mime type from a filename, but not from a filehandle. I
haven't figured out how to get MIME::Types to use a filehandle.
In digging around some more, I found Media::Type::Simple, which could be
fed either one, which seemed perfect, but there's a glaring bug where
the module doesn't work in a forked environment, which I assume will
have a bad effect in web apps.
So I either need to get MTS fixed (there's a patch in RT) or find
another module that will do the trick.