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 cgi = Keyword.fetch!(settings, :cgi)
9 files = Keyword.fetch!(settings, :files)
11 {:ok, file_data} = File.read(path)
15 extension = String.split(name, ".") |> List.last()
16 query = "#{cgi}?#{extension}"
18 with {:ok, %{status_code: 200, body: body}} <- @httpoison.post(query, file_data) do
19 remote_file_name = String.split(body) |> List.first()
20 public_url = "#{files}/#{remote_file_name}.#{extension}"