mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-22 13:23:09 +01:00
16 lines
No EOL
334 B
Elixir
16 lines
No EOL
334 B
Elixir
defmodule Philomena.Mime do
|
|
@doc """
|
|
Gets the MIME type of the given pathname.
|
|
"""
|
|
@spec file(String.t()) :: {:ok, binary()} | :error
|
|
def file(path) do
|
|
System.cmd("file", ["-b", "--mime-type", path])
|
|
|> case do
|
|
{output, 0} ->
|
|
{:ok, String.trim(output)}
|
|
|
|
_error ->
|
|
:error
|
|
end
|
|
end
|
|
end |