Unique filename fixed.

This commit is contained in:
codevictory
2021-06-01 21:44:39 +03:00
parent d1571414d7
commit 526beedbe9

View File

@@ -23,7 +23,7 @@ defmodule RunosaariWeb.PerformerController do
%{"photo" => photo_params} = performer_params %{"photo" => photo_params} = performer_params
file_uuid = UUID.uuid4(:hex) file_uuid = UUID.uuid4(:hex)
photo_filename = photo_params.filename photo_filename = photo_params.filename
unique_filename = "#{file_uuid}-#{photo_filename}" unique_filename = "performer_photos/#{file_uuid}-#{photo_filename}"
{:ok, photo_binary} = File.read(photo_params.path) {:ok, photo_binary} = File.read(photo_params.path)
bucket_name = System.get_env("S3_BUCKET_NAME") bucket_name = System.get_env("S3_BUCKET_NAME")
public_host = System.get_env("S3_PUBLIC_HOST") public_host = System.get_env("S3_PUBLIC_HOST")
@@ -36,7 +36,7 @@ defmodule RunosaariWeb.PerformerController do
|> Map.delete("photo") |> Map.delete("photo")
|> Map.put( |> Map.put(
"photo_path", "photo_path",
"https://#{public_host}/#{bucket_name}/performer_photos/#{unique_filename}" "https://#{public_host}/#{bucket_name}/#{unique_filename}"
) )
case Registration.create_performer(updated_params) do case Registration.create_performer(updated_params) do