add mdii uploader
authorHakaba Hitoyo <hakabahitoyo@example.com>
Thu, 15 Nov 2018 05:19:10 +0000 (14:19 +0900)
committerHakaba Hitoyo <hakabahitoyo@example.com>
Thu, 15 Nov 2018 05:19:10 +0000 (14:19 +0900)
config/config.exs
lib/pleroma/uploaders/mdii.ex [new file with mode: 0644]

index 9cc55856463b41f2e36f49606404204bf5abed85..ef69368e64f625637af3e4675a3b7be68ba735a8 100644 (file)
@@ -23,6 +23,9 @@ config :pleroma, Pleroma.Uploaders.S3,
   public_endpoint: "https://s3.amazonaws.com",
   force_media_proxy: false
 
+config :pleroma, Pleroma.Uploaders.Mdii,
+  host_name: "mdii.sakura.ne.jp"
+
 config :pleroma, :emoji, shortcode_globs: ["/emoji/custom/**/*.png"]
 
 config :pleroma, :uri_schemes,
diff --git a/lib/pleroma/uploaders/mdii.ex b/lib/pleroma/uploaders/mdii.ex
new file mode 100644 (file)
index 0000000..3cf71df
--- /dev/null
@@ -0,0 +1,19 @@
+defmodule Pleroma.Uploaders.Mdii do
+  @behaviour Pleroma.Uploaders.Uploader
+
+  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)
+
+    {:ok, file_data} = File.read(path)
+
+    File.rm!(path)
+
+    remote_file_name = "00000"
+    extension = "png"
+
+    public_url = "https://#{host_name}/#{remote_file_name}.#{extension}"
+
+    {:ok, public_url}
+  end
+end