Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Looking for a name (Magic number MIME information on file from freedesktop.org database)

by Perlbotics (Archbishop)
on Sep 17, 2016 at 15:18 UTC ( [id://1172006]=note: print w/replies, xml ) Need Help??


in reply to Looking for a name (Magic number MIME information on file from freedesktop.org database)

How about MIME::Detect which could implement a generic API or a driver (like DBI) that can interface to various backends like the ones you already listed?
MIME::Detect::SharedMimeInfoXML could then be one of many backends.

my $mime_detector = MIME::Detect->new( driver => 'auto' ); could auto-select an available backend.
my $mime_detector = MIME::Detect->new( driver => 'SharedMimeInfoXML' ); would ask for a specific driver explicitly.

More work needs to be done for the API to cover most of the existing functionality, though. However, work already done by others can be preserved and made available in a generic way.

Leaving the FILE:: namespace aside would also allow to broaden the application of MIME-detection to streams (i.e. using IO::Handle), strings, etc.

  • Comment on Re: Looking for a name (Magic number MIME information on file from freedesktop.org database)
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Looking for a name (Magic number MIME information on file from freedesktop.org database)
by Corion (Patriarch) on Sep 17, 2016 at 21:06 UTC

    At least File::MimeInfo and my module already support filehandles and in-memory streams as well, so that part is covered. I like the idea of leaving File:: out, as it shortens the module name.

    Personally, I've stopped trying to create "generic" modules together with the first implementation, as normally it turned out that my first implementation remained the only implementation and no plugins or other drivers turned up. But using MIME::Detect as the API class and leaving the door open for others to add backends sounds good.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1172006]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-24 23:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found