diff options
author | Hakaba Hitoyo <hakabahitoyo@example.com> | 2018-11-15 14:38:45 +0900 |
---|---|---|
committer | Hakaba Hitoyo <hakabahitoyo@example.com> | 2018-11-15 14:38:45 +0900 |
commit | 698cb3587cf66f4946c2baab69ecd45f339e1392 (patch) | |
tree | a5038f7e4267bfa0b7f46a45938999494a59863c /lib | |
parent | 58af0787be605d0b382b30aba3749c7c8bbf10bc (diff) | |
download | pleroma-698cb3587cf66f4946c2baab69ecd45f339e1392.tar.gz |
omplement mdii uploader
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/uploaders/mdii.ex | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/pleroma/uploaders/mdii.ex b/lib/pleroma/uploaders/mdii.ex index 3cf71df43..f21a7e1e2 100644 --- a/lib/pleroma/uploaders/mdii.ex +++ b/lib/pleroma/uploaders/mdii.ex @@ -1,6 +1,8 @@ defmodule Pleroma.Uploaders.Mdii do @behaviour Pleroma.Uploaders.Uploader + @httpoison Application.get_env(:pleroma, :httpoison) + 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) @@ -8,12 +10,15 @@ defmodule Pleroma.Uploaders.Mdii do {:ok, file_data} = File.read(path) File.rm!(path) + + extension = Regex.replace(~r/^image\//, content_type, "") + query = "https://#{host_name}/mdii.cgi?#{extension}" - remote_file_name = "00000" - extension = "png" - - public_url = "https://#{host_name}/#{remote_file_name}.#{extension}" - - {:ok, public_url} + with {:ok, %{status_code: 200, body: body}} <- + @httpoison.get(url, file_data) do + remote_file_name = body + public_url = "https://#{host_name}/#{remote_file_name}.#{extension}" + {:ok, public_url} + end end end |