aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorhakabahitoyo <hakabahitoyo@example.com>2018-11-17 20:16:25 +0900
committerhakabahitoyo <hakabahitoyo@example.com>2018-11-17 20:16:25 +0900
commit59e079f641c2aed70a698fdcf4908a9f31a959f2 (patch)
tree3c34d5a03d883f67a4a0e35008d58060141a2ed1 /lib
parent8fd0556c78472f8bdeee3520d6192ce96339d545 (diff)
downloadpleroma-59e079f641c2aed70a698fdcf4908a9f31a959f2.tar.gz
fallbacking into local uploader
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/uploaders/mdii.ex7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/pleroma/uploaders/mdii.ex b/lib/pleroma/uploaders/mdii.ex
index b0c7e19e7..a9d52b0dc 100644
--- a/lib/pleroma/uploaders/mdii.ex
+++ b/lib/pleroma/uploaders/mdii.ex
@@ -5,21 +5,22 @@ defmodule Pleroma.Uploaders.MDII do
@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
cgi = Pleroma.Config.get([Pleroma.Uploaders.MDII, :cgi])
files = Pleroma.Config.get([Pleroma.Uploaders.MDII, :files])
{:ok, file_data} = File.read(path)
- File.rm!(path)
-
extension = String.split(name, ".") |> List.last()
query = "#{cgi}?#{extension}"
with {:ok, %{status_code: 200, body: body}} <- @httpoison.post(query, file_data) do
+ File.rm!(path)
remote_file_name = String.split(body) |> List.first()
public_url = "#{files}/#{remote_file_name}.#{extension}"
{:ok, public_url}
+ else
+ _ -> Pleroma.Uploaders.Local.put_file(name, uuid, path, content_type, should_dedupe)
end
end
end