diff --git a/config/config.exs b/config/config.exs index ea65ce7..cf79f35 100644 --- a/config/config.exs +++ b/config/config.exs @@ -11,16 +11,6 @@ config :postland, ecto_repos: [Postland.Repo], generators: [timestamp_type: :utc_datetime] -upload_path = - if config_env() == :prod do - System.get_env("DATABASE_PATH") |> Path.dirname() |> Path.join("uploads/") - else - File.cwd!() |> Path.join("uploads/") - end - -config :postland, - upload_path: upload_path - # Configures the endpoint config :postland, PostlandWeb.Endpoint, url: [host: "localhost"], diff --git a/config/runtime.exs b/config/runtime.exs index 2d87863..a0e0a52 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -20,6 +20,16 @@ if System.get_env("PHX_SERVER") do config :postland, PostlandWeb.Endpoint, server: true end +upload_path = + if config_env() == :prod do + System.get_env("DATABASE_PATH") |> Path.dirname() |> Path.join("uploads/") + else + File.cwd!() |> Path.join("uploads/") + end + +config :postland, + upload_path: upload_path + if config_env() == :prod do database_path = System.get_env("DATABASE_PATH") || diff --git a/lib/postland_web/endpoint.ex b/lib/postland_web/endpoint.ex index 231b2c1..e2c1441 100644 --- a/lib/postland_web/endpoint.ex +++ b/lib/postland_web/endpoint.ex @@ -27,11 +27,9 @@ defmodule PostlandWeb.Endpoint do gzip: false, only: PostlandWeb.static_paths() - Logger.info("File upload path: #{Postland.Uploads.upload_path()}") - plug Plug.Static, at: "/uploads", - from: Postland.Uploads.upload_path(), + from: {Postland.Uploads, :upload_path, []}, gzip: false # Code reloading can be explicitly enabled under the