From 58af0787be605d0b382b30aba3749c7c8bbf10bc Mon Sep 17 00:00:00 2001 From: Hakaba Hitoyo Date: Thu, 15 Nov 2018 14:19:10 +0900 Subject: [PATCH] add mdii uploader --- config/config.exs | 3 +++ lib/pleroma/uploaders/mdii.ex | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 lib/pleroma/uploaders/mdii.ex diff --git a/config/config.exs b/config/config.exs index 9cc558564..ef69368e6 100644 --- a/config/config.exs +++ b/config/config.exs @@ -23,6 +23,9 @@ config :pleroma, Pleroma.Uploaders.S3, public_endpoint: "https://s3.amazonaws.com", force_media_proxy: false +config :pleroma, Pleroma.Uploaders.Mdii, + host_name: "mdii.sakura.ne.jp" + config :pleroma, :emoji, shortcode_globs: ["/emoji/custom/**/*.png"] config :pleroma, :uri_schemes, diff --git a/lib/pleroma/uploaders/mdii.ex b/lib/pleroma/uploaders/mdii.ex new file mode 100644 index 000000000..3cf71df43 --- /dev/null +++ b/lib/pleroma/uploaders/mdii.ex @@ -0,0 +1,19 @@ +defmodule Pleroma.Uploaders.Mdii do + @behaviour Pleroma.Uploaders.Uploader + + def put_file(name, uuid, path, content_type, _should_dedupe) do + settings = Application.get_env(:pleroma, Pleroma.Uploaders.Mdii) + host_name = Keyword.fetch!(settings, :host_name) + + {:ok, file_data} = File.read(path) + + File.rm!(path) + + remote_file_name = "00000" + extension = "png" + + public_url = "https://#{host_name}/#{remote_file_name}.#{extension}" + + {:ok, public_url} + end +end