Awesome
Sizeable
<!-- MDOC !-->An Elixir library to make file sizes human-readable.
Installation
The package can be installed as:
-
Add
:sizeable
to your list of dependencies inmix.exs
:def deps do [ {:sizeable, "~> 1.0"} ] end
-
Ensure
sizeable
is started before your application if you're using Elixir 1.3 or lower:def application do [ applications: [:sizeable] ] end
Usage
Get file size for 1024 bytes
Sizeable.filesize(1024)
"1 KB"
Get bit-sized file size for 1024 bytes
Sizeable.filesize(1024, bits: true)
"8 Kb"
Get output format as list
Sizeable.filesize(1024, output: :list)
[1, "KB"]
Get output format as map
Sizeable.filesize(1024, output: :map)
%{result: 1, unit: "KB"}
Read Sizeable.filesize/2 for further usage details.
<!-- MDOC !-->Copyright and License
Copyright (c) 2016 Arvid Kahl
This software is licensed under the MIT license.