philomena/lib/philomena/filename.ex

22 lines
422 B
Elixir
Raw Normal View History

2019-12-07 06:49:20 +01: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-09 01:08:53 +01:00
UUID.uuid1(),
2019-12-07 06:49:20 +01:00
".",
extension
]
|> Enum.join()
end
defp time_identifier(time) do
Enum.join([time.year, time.month, time.day], "/")
end
2020-01-11 05:20:19 +01:00
end