struct Athena::MIME::MagicTypesGuesser

Overview

A AMIME::TypesGuesserInterface implementation based on libmagic.

Only natively supported on Unix systems and MSYS2 where the file package is easily installable. If you have the available lib files on Windows MSVC you may build with -Dathena_use_libmagic to explicitly enable the implementation.

Included Modules

Defined in:

magic_types_guesser.cr

Constructors

Instance Method Summary

Instance methods inherited from module Athena::MIME::TypesGuesserInterface

guess_mime_type(path : String | Path) : String | Nil guess_mime_type, supported? : Bool supported?

Constructor Detail

def self.new(magic_file : String | Nil = nil) #

[View source]

Instance Method Detail

def guess_mime_type(path : String | Path) : String | Nil #

Returns the guessed MIME type for the file at the provided path, or nil if it could not be determined.

How exactly the MIME type is determined is up to each individual implementation.

guesser.guess_mime_type "/path/to/image.png" # => "image/png"

[View source]
def supported? : Bool #

Returns true if this guesser is supported, otherwise false.

The value may be cached on the class level.


[View source]