1 defmodule Pleroma.Uploaders.Mdii do
2 @behaviour Pleroma.Uploaders.Uploader
4 @httpoison Application.get_env(:pleroma, :httpoison)
6 def put_file(name, uuid, path, content_type, _should_dedupe) do
7 settings = Application.get_env(:pleroma, Pleroma.Uploaders.Mdii)
8 host_name = Keyword.fetch!(settings, :host_name)
10 {:ok, file_data} = File.read(path)
14 extension = Regex.replace(~r/^image\//, content_type, "")
15 query = "https://#{host_name}/mdii.cgi?#{extension}"
17 with {:ok, %{status_code: 200, body: body}} <-
18 @httpoison.get(url, file_data) do
19 remote_file_name = body
20 public_url = "https://#{host_name}/#{remote_file_name}.#{extension}"