X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fuploaders%2Fs3.ex;h=e7de3f3e0de84da366987a3b0a89ca9429080c20;hb=92a0210fb03ca3e0aefe769fb6b0ab7bda6e5336;hp=108cf06b555aaf86e8cfdd09ebc1e66a66eb2076;hpb=b73a1a33de76dc848037a5d0e951866bd21f92c4;p=akkoma diff --git a/lib/pleroma/uploaders/s3.ex b/lib/pleroma/uploaders/s3.ex index 108cf06b5..e7de3f3e0 100644 --- a/lib/pleroma/uploaders/s3.ex +++ b/lib/pleroma/uploaders/s3.ex @@ -6,20 +6,29 @@ defmodule Pleroma.Uploaders.S3 do @behaviour Pleroma.Uploaders.Uploader require Logger - # The file name is re-encoded with S3's constraints here to comply with previous links with less strict filenames + # 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 - def put_file(upload = %Pleroma.Upload{}) do + def put_file(%Pleroma.Upload{} = upload) do config = Pleroma.Config.get([__MODULE__]) bucket = Keyword.get(config, :bucket)