philomena/lib/philomena/filename.ex

22 lines
422 B
Elixir
Raw Normal View History

2019-12-07 00:49:20 -05:00
defmodule Philomena.Filename do
@moduledoc """
Utilities for building arbitrary filenames for uploaded files.
"""
@spec build(String.t()) :: String.t()
def build(extension) do
[
time_identifier(DateTime.utc_now()),
"/",
2022-02-08 19:08:53 -05:00
UUID.uuid1(),
2019-12-07 00:49:20 -05:00
".",
extension
]
|> Enum.join()
end
defp time_identifier(time) do
Enum.join([time.year, time.month, time.day], "/")
end
2020-01-10 23:20:19 -05:00
end