[Pleroma.Uploaders.Local]: Add configuration for custom url path

One use-case being an external caching proxy
This commit is contained in:
Haelwenn (lanodan) Monnier 2018-09-01 17:14:14 +02:00
parent b7923aa304
commit 754deb26dd
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
2 changed files with 8 additions and 2 deletions

View file

@ -14,7 +14,9 @@
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,

View file

@ -42,6 +42,10 @@ defp get_url(name, uuid, should_dedupe) 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