From 754deb26dd7ad9bf431d6d3edc3004b4f27ca8b0 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 1 Sep 2018 17:14:14 +0200 Subject: [PATCH] [Pleroma.Uploaders.Local]: Add configuration for custom url path One use-case being an external caching proxy --- config/config.exs | 4 +++- lib/pleroma/uploaders/local.ex | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config/config.exs b/config/config.exs index b29300c3c..3dd8ef284 100644 --- a/config/config.exs +++ b/config/config.exs @@ -14,7 +14,9 @@ config :pleroma, Pleroma.Upload, uploader: Pleroma.Uploaders.Local, strip_exif: false -config :pleroma, Pleroma.Uploaders.Local, uploads: "uploads" +config :pleroma, Pleroma.Uploaders.Local, + uploads: "uploads", + uploads_url: "{{base_url}}/media/{{file}}" config :pleroma, Pleroma.Uploaders.S3, bucket: nil, diff --git a/lib/pleroma/uploaders/local.ex b/lib/pleroma/uploaders/local.ex index d4624661f..d96481c8d 100644 --- a/lib/pleroma/uploaders/local.ex +++ b/lib/pleroma/uploaders/local.ex @@ -42,6 +42,10 @@ defmodule Pleroma.Uploaders.Local do end defp url_for(file) do - "#{Web.base_url()}/media/#{file}" + settings = Application.get_env(:pleroma, Pleroma.Uploaders.Local) + + Keyword.get(settings, :uploads_url) + |> String.replace("{{file}}", file) + |> String.replace("{{base_url}}", Web.base_url()) end end -- 2.45.2