How do I make uploaded images copied in priv folder of one of the apps in the umbrella project in phoenix 1.7.11 and phoenix liveview 0.20

I have an umbrella application where I am implementing the image upload functionality. The application has two apps, blog_web, and admin. The functionality of uploading the images is handled by the admin app using LiveView. This is the post-creation code:

def handle_event("save", %{"post" => post_params}, socket) do
    image_locations =
      consume_uploaded_entries(socket, :image, fn meta, entry ->
        destination_dir = Path.join([:code.priv_dir(:blog_web), "static", "uploads"])

        destination = Path.join([destination_dir, "#{entry.uuid}-#{entry.client_name}"])

        File.cp!(meta.path, destination)

        file_path = static_path(socket, "/uploads/#{Path.basename(destination)}")

        {:ok, file_path}
      end)

    params = Map.put(post_params, "image", List.first(image_locations))

    IO.inspect(params, label: "Updated Post Params")

    case Catalog.create_post(params) do
      {:ok, _post} ->
        changeset = Catalog.change_post(%Post{})
        {:noreply, assign(socket, form: to_form(changeset), check_errors: false)}

      {:error, changeset} ->
        {:noreply, assign(socket, form: to_form(changeset), check_errors: true)}
    end
  end

This code create a post and I get back this successfull query:

[debug] QUERY OK source="posts" db=2.7ms queue=0.4ms idle=1339.8ms
INSERT INTO "posts" ("active","title","image","user_id","content","category_id","inserted_at","updated_at") VALUES ($1,$2,$3,$4,$5,$6,$7,$8) RETURNING "id" [false, "What is vue js", "/uploads/47580510-9c5d-4ccb-bcb0-e8fa2895d3d2-Vue.js_Logo_2.svg.png", 1, "Vue js is the most beautiful front-end framework", 1, ~N[2024-03-05 19:10:05], ~N[2024-03-05 19:10:05]]

The only problem is that the images are not copied to the specified directories.

How am I supposed to specify the uploads folder path so that the images would be moved to the priv path of the blog_web dir or any suggestions on the appropriate dir to store the images and the how to alter the code to do that. Thanks.

In development/testing, did you look for your files at ./priv or at ./build/<your runtime>/lib/<your app name>/priv? It should be the latter. I think ./priv contains the files before compilation but will not be read by the running instance of your app (changes to it will trigger a recompilation though).