From 3c936061d55c1c4bd9346471bc498dd123395766 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Fri, 8 Jan 2021 10:49:12 -0600 Subject: [PATCH] Apply Upload.base_url for S3 --- lib/pleroma/uploaders/s3.ex | 2 +- test/pleroma/uploaders/s3_test.exs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/pleroma/uploaders/s3.ex b/lib/pleroma/uploaders/s3.ex index 6dbef9085..5a91410d7 100644 --- a/lib/pleroma/uploaders/s3.ex +++ b/lib/pleroma/uploaders/s3.ex @@ -30,7 +30,7 @@ def get_file(file) do {:ok, {:url, Path.join([ - Keyword.fetch!(config, :public_endpoint), + Pleroma.Upload.base_url(), bucket_with_namespace, strict_encode(URI.decode(file)) ])}} diff --git a/test/pleroma/uploaders/s3_test.exs b/test/pleroma/uploaders/s3_test.exs index e7a013dd8..344cf7abe 100644 --- a/test/pleroma/uploaders/s3_test.exs +++ b/test/pleroma/uploaders/s3_test.exs @@ -11,11 +11,16 @@ defmodule Pleroma.Uploaders.S3Test do import Mock import ExUnit.CaptureLog - setup do: - clear_config(Pleroma.Uploaders.S3, - bucket: "test_bucket", - public_endpoint: "https://s3.amazonaws.com" - ) + setup do + clear_config(Pleroma.Upload, + uploader: Pleroma.Uploaders.S3 + ) + + clear_config(Pleroma.Uploaders.S3, + bucket: "test_bucket", + public_endpoint: "https://s3.amazonaws.com" + ) + end describe "get_file/1" do test "it returns path to local folder for files" do