Deprecate Pleroma.Uploaders.S3, :public_endpoint
This commit is contained in:
parent
5453038ce9
commit
8b28dce82a
|
@ -64,14 +64,23 @@
|
|||
link_name: false,
|
||||
proxy_remote: false,
|
||||
filename_display_max_length: 30,
|
||||
default_description: nil
|
||||
default_description: nil,
|
||||
base_url: nil
|
||||
|
||||
config :pleroma, Pleroma.Uploaders.Local, uploads: "uploads"
|
||||
|
||||
config :pleroma, Pleroma.Uploaders.S3,
|
||||
bucket: nil,
|
||||
streaming_enabled: true,
|
||||
public_endpoint: "https://s3.amazonaws.com"
|
||||
bucket_namespace: nil,
|
||||
truncated_namespace: false,
|
||||
streaming_enabled: true
|
||||
|
||||
config :ex_aws, :s3,
|
||||
# host: "s3.wasabisys.com", # required if not Amazon AWS
|
||||
access_key_id: nil,
|
||||
secret_access_key: nil,
|
||||
# region: nil, # example: "us-east-1"
|
||||
scheme: "https://"
|
||||
|
||||
config :pleroma, :emoji,
|
||||
shortcode_globs: ["/emoji/custom/**/*.png"],
|
||||
|
|
|
@ -149,18 +149,12 @@
|
|||
description: "S3 bucket namespace",
|
||||
suggestions: ["pleroma"]
|
||||
},
|
||||
%{
|
||||
key: :public_endpoint,
|
||||
type: :string,
|
||||
description: "S3 endpoint",
|
||||
suggestions: ["https://s3.amazonaws.com"]
|
||||
},
|
||||
%{
|
||||
key: :truncated_namespace,
|
||||
type: :string,
|
||||
description:
|
||||
"If you use S3 compatible service such as Digital Ocean Spaces or CDN, set folder name or \"\" etc." <>
|
||||
" For example, when using CDN to S3 virtual host format, set \"\". At this time, write CNAME to CDN in public_endpoint."
|
||||
" For example, when using CDN to S3 virtual host format, set \"\". At this time, write CNAME to CDN in Upload base_url."
|
||||
},
|
||||
%{
|
||||
key: :streaming_enabled,
|
||||
|
|
|
@ -117,8 +117,7 @@
|
|||
|
||||
config :pleroma, Pleroma.Uploaders.S3,
|
||||
bucket: nil,
|
||||
streaming_enabled: true,
|
||||
public_endpoint: nil
|
||||
streaming_enabled: true
|
||||
|
||||
config :tzdata, :autoupdate, :disabled
|
||||
|
||||
|
|
|
@ -549,7 +549,7 @@ the source code is here: [kocaptcha](https://github.com/koto-bank/kocaptcha). Th
|
|||
* `uploader`: Which one of the [uploaders](#uploaders) to use.
|
||||
* `filters`: List of [upload filters](#upload-filters) to use.
|
||||
* `link_name`: When enabled Pleroma will add a `name` parameter to the url of the upload, for example `https://instance.tld/media/corndog.png?name=corndog.png`. This is needed to provide the correct filename in Content-Disposition headers when using filters like `Pleroma.Upload.Filter.Dedupe`
|
||||
* `base_url`: The base URL to access a user-uploaded file. Useful when you want to proxy the media files via another host.
|
||||
* `base_url`: The base URL to access a user-uploaded file. Useful when you want to host the media files via another domain or are using a 3rd party S3 provider.
|
||||
* `proxy_remote`: If you're using a remote uploader, Pleroma will proxy media requests instead of redirecting to it.
|
||||
* `proxy_opts`: Proxy options, see `Pleroma.ReverseProxy` documentation.
|
||||
* `filename_display_max_length`: Set max length of a filename to display. 0 = no limit. Default: 30.
|
||||
|
@ -570,10 +570,7 @@ Don't forget to configure [Ex AWS S3](#ex-aws-s3-settings)
|
|||
|
||||
* `bucket`: S3 bucket name.
|
||||
* `bucket_namespace`: S3 bucket namespace.
|
||||
* `public_endpoint`: S3 endpoint that the user finally accesses(ex. "https://s3.dualstack.ap-northeast-1.amazonaws.com")
|
||||
* `truncated_namespace`: If you use S3 compatible service such as Digital Ocean Spaces or CDN, set folder name or "" etc.
|
||||
For example, when using CDN to S3 virtual host format, set "".
|
||||
At this time, write CNAME to CDN in public_endpoint.
|
||||
* `streaming_enabled`: Enable streaming uploads, when enabled the file will be sent to the server in chunks as it's being read. This may be unsupported by some providers, try disabling this if you have upload problems.
|
||||
|
||||
#### Ex AWS S3 settings
|
||||
|
|
|
@ -40,7 +40,8 @@ def warn do
|
|||
:ok <- check_welcome_message_config(),
|
||||
:ok <- check_gun_pool_options(),
|
||||
:ok <- check_activity_expiration_config(),
|
||||
:ok <- check_remote_ip_plug_name() do
|
||||
:ok <- check_remote_ip_plug_name(),
|
||||
:ok <- check_uploders_s3_public_endpoint() do
|
||||
:ok
|
||||
else
|
||||
_ ->
|
||||
|
@ -193,4 +194,25 @@ def check_remote_ip_plug_name do
|
|||
warning_preface
|
||||
)
|
||||
end
|
||||
|
||||
@spec check_uploders_s3_public_endpoint() :: :ok | nil
|
||||
def check_uploders_s3_public_endpoint do
|
||||
s3_config = Pleroma.Config.get([Pleroma.Uploaders.S3])
|
||||
|
||||
use_old_config = Keyword.has_key?(s3_config, :public_endpoint)
|
||||
|
||||
if use_old_config do
|
||||
Logger.error("""
|
||||
!!!DEPRECATION WARNING!!!
|
||||
Your config is using the old setting for controlling the URL of media uploaded to your S3 bucket.\n
|
||||
Please make the following change at your earliest convenience.\n
|
||||
\n* `config :pleroma, Pleroma.Uploaders.S3, public_endpoint` is now equal to:
|
||||
\n* `config :pleroma, Pleroma.Upload, base_url`
|
||||
""")
|
||||
|
||||
:error
|
||||
else
|
||||
:ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,12 +49,18 @@ config :pleroma, Pleroma.Uploaders.Local, uploads: "<%= uploads_dir %>"
|
|||
# sts: true
|
||||
|
||||
# Configure S3 support if desired.
|
||||
# The public S3 endpoint is different depending on region and provider,
|
||||
# The public S3 endpoint (base_url) is different depending on region and provider,
|
||||
# consult your S3 provider's documentation for details on what to use.
|
||||
#
|
||||
# config :pleroma, Pleroma.Upload,
|
||||
# uploader: Pleroma.Uploaders.S3,
|
||||
# base_url: "https://s3.amazonaws.com"
|
||||
#
|
||||
# config :pleroma, Pleroma.Uploaders.S3,
|
||||
# bucket: "some-bucket",
|
||||
# public_endpoint: "https://s3.amazonaws.com"
|
||||
# bucket_namespace: "my-namespace",
|
||||
# truncated_namespace: false,
|
||||
# streaming_enabled: true
|
||||
#
|
||||
# Configure S3 credentials:
|
||||
# config :ex_aws, :s3,
|
||||
|
|
|
@ -94,6 +94,15 @@ test "check_activity_expiration_config/0" do
|
|||
end) =~ "Your config is using old namespace for activity expiration configuration."
|
||||
end
|
||||
|
||||
test "check_uploders_s3_public_endpoint/0" do
|
||||
clear_config(Pleroma.Uploaders.S3, public_endpoint: "https://fake.amazonaws.com/bucket/")
|
||||
|
||||
assert capture_log(fn ->
|
||||
DeprecationWarnings.check_uploders_s3_public_endpoint()
|
||||
end) =~
|
||||
"Your config is using the old setting for controlling the URL of media uploaded to your S3 bucket."
|
||||
end
|
||||
|
||||
describe "check_gun_pool_options/0" do
|
||||
test "await_up_timeout" do
|
||||
config = Config.get(:connections_pool)
|
||||
|
|
Loading…
Reference in a new issue