Geo
Geo

Reputation: 96767

What should I use to detect mimetypes reliably?

I tried using mimetype-fu to detect mimetypes, but it seems to work for some files, while for others it doesn't. For example, I downloaded this R manual, and I tried to detect it's mimetype, via:

File.mime_type?(File.read("R-intro.pdf"))

and it tells me that the mimetype is "unknown/unknown". Is there another way of detecting mimetypes? Is there maybe another mimetype-fu option that I'm not aware of, that could handle this case?

Upvotes: 1

Views: 289

Answers (1)

apneadiving
apneadiving

Reputation: 115511

As discussed in comments, filemagic is a good fit.

Upvotes: 1

Related Questions