Add convenience to store images

This commit is contained in:
Claudio Ortolina
2025-09-01 11:03:30 +03:00
parent a605610c9d
commit db843bf061
3 changed files with 59 additions and 0 deletions
+13
View File
@@ -2,9 +2,22 @@ defmodule MusicLibrary.Assets do
alias MusicLibrary.Assets.Asset
alias MusicLibrary.Repo
@doc """
Store any file type - the responsibility to correctly populate format and
properties is left to the caller.
"""
def store(params) do
%Asset{}
|> Asset.changeset(params)
|> Repo.insert()
end
@doc """
Store image files - properties will be computed automatically.
"""
def store_image(params) do
%Asset{}
|> Asset.image_changeset(params)
|> Repo.insert()
end
end