i have stored image using waffle in my local storage due to it , i face storage issue , do waffle versioning helps in reducing the storage space , so i tried in transforming it in thumb version but it leads to match error how to resolve
@versions [:original, :thumb]
def acl(:original, _), do: :public_read
def acl(:thumb, _), do: :public_read
@extension_whitelist ~w(.jpg .jpeg .gif .png .xlsx .word .pdf .txt .vue .ex .json .webp)
def validate({file, _}) do
file_extension = file.file_name |> Path.extname |> String.downcase
IO.inspect(file_extension)
case Enum.member?(@extension_whitelist, file_extension) do
true -> :ok
false -> {:error, "file type is invalid"}
end
end
def transform(:thumb, _scope) do
{:convert, "-strip -thumbnail 100x100^ -gravity center -extent 100x100"}
end
def filename(version, {file, _scope}) do
actual_file_without_flags = String.split("#{file.file_name}", "*~*~*~*~*")
[name, _] = String.split(List.last(actual_file_without_flags),".")
"#{version}_#{name}"
end
def storage_dir(_version, {_file, scope}) do
"/#{scope.trnx_year}/#{scope.trnx_type}"
end
this is the func i have used to store the image:
def bulk_image_upload_purchase_order(conn, params) do
image_attached = params["image_upload"]
case image_attached do
nil ->
json(conn, %{"status" => "No images attached"})
[] ->
nil
_ ->
for param <- image_attached do
first_split = String.split("#{param.filename}", "*~*~*~*~*")
second_split = String.split(List.first(first_split), "#@#@#@#@#")
trnx_year = if List.first(second_split), do: List.first(second_split), else: NaiveDateTime.utc_now().year
trnx_type = if List.last(second_split), do: List.last(second_split), else: "Common"
scope = %{trnx_year: trnx_year, trnx_type: trnx_type}
{:ok, file_name} = Avatar_Local.store({param, scope})
# :ok = Avatar_Local.delete({file_name, scope})
end
json(conn, %{"status" => "Uploaded Successfully"})
end
end