omplement mdii uploader

This commit is contained in:
Hakaba Hitoyo 2018-11-15 14:38:45 +09:00
parent 58af0787be
commit 698cb3587c

View File

@ -1,6 +1,8 @@
defmodule Pleroma.Uploaders.Mdii do defmodule Pleroma.Uploaders.Mdii do
@behaviour Pleroma.Uploaders.Uploader @behaviour Pleroma.Uploaders.Uploader
@httpoison Application.get_env(:pleroma, :httpoison)
def put_file(name, uuid, path, content_type, _should_dedupe) do def put_file(name, uuid, path, content_type, _should_dedupe) do
settings = Application.get_env(:pleroma, Pleroma.Uploaders.Mdii) settings = Application.get_env(:pleroma, Pleroma.Uploaders.Mdii)
host_name = Keyword.fetch!(settings, :host_name) host_name = Keyword.fetch!(settings, :host_name)
@ -9,11 +11,14 @@ defmodule Pleroma.Uploaders.Mdii do
File.rm!(path) File.rm!(path)
remote_file_name = "00000" extension = Regex.replace(~r/^image\//, content_type, "")
extension = "png" query = "https://#{host_name}/mdii.cgi?#{extension}"
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}" public_url = "https://#{host_name}/#{remote_file_name}.#{extension}"
{:ok, public_url} {:ok, public_url}
end end
end
end end