Created
October 10, 2016 12:54
-
-
Save radzserg/9f1472801b6b8f8588176f46c59158a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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