Skip to content

Instantly share code, notes, and snippets.

@radzserg
Created October 10, 2016 12:54
Show Gist options
  • Select an option

  • Save radzserg/9f1472801b6b8f8588176f46c59158a5 to your computer and use it in GitHub Desktop.

Select an option

Save radzserg/9f1472801b6b8f8588176f46c59158a5 to your computer and use it in GitHub Desktop.
defmodule App.Helpers.FileHelper do
def get_mime!(path) do
{result, 0} = System.cmd("file", ["--mime-type"|[path]])
result
|> String.split(":")
|> List.last
|> String.trim
|> String.downcase
end
def get_size!(path) do
stat = File.stat! path
stat.size
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment