Skip to content

Commit

Permalink
fix: uploader.ex restored
Browse files Browse the repository at this point in the history
  • Loading branch information
AfonsoMartins26 committed Oct 4, 2024
1 parent d973f50 commit 254e5ec
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions lib/atomic/uploader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,18 @@ defmodule Atomic.Uploader do
use Waffle.Definition
use Waffle.Ecto.Definition

def validate(file, _) do
def validate({file, _}) do
file_extension = file.file_name |> Path.extname() |> String.downcase()

case Enum.member?(extension_whitelist(), file_extension) do
true ->
if file.size <= max_size() do
:ok
else
{:error, "file size exceeds maximum allowed size"}
end

false ->
{:error, "invalid file extension"}
true -> :ok
false -> {:error, "invalid file extension"}
end
end

def extension_whitelist do
Keyword.get(unquote(opts), :extensions, [])
end

def max_size do
Keyword.get(unquote(opts), :max_size, 500)
end
end
end
end

0 comments on commit 254e5ec

Please sign in to comment.