From: href Date: Mon, 21 Jan 2019 13:42:16 +0000 (+0100) Subject: S3 Namespace X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=97412d9f94ed55caecb7a35e1f95aef7bdf0db19;p=akkoma S3 Namespace --- diff --git a/lib/pleroma/uploaders/s3.ex b/lib/pleroma/uploaders/s3.ex index 108cf06b5..fbd89616c 100644 --- a/lib/pleroma/uploaders/s3.ex +++ b/lib/pleroma/uploaders/s3.ex @@ -9,12 +9,20 @@ defmodule Pleroma.Uploaders.S3 do # The file name is re-encoded with S3's constraints here to comply with previous links with less strict filenames def get_file(file) do config = Pleroma.Config.get([__MODULE__]) + bucket = Keyword.fetch!(config, :bucket) + + bucket_with_namespace = + if namespace = Keyword.get(config, :bucket_namespace) do + namespace <> ":" <> bucket + else + bucket + end {:ok, {:url, Path.join([ Keyword.fetch!(config, :public_endpoint), - Keyword.fetch!(config, :bucket), + bucket_with_namespace, strict_encode(URI.decode(file)) ])}} end