giant massive dep upgrade and dialyxir-found error emporium (#371)
[akkoma] / lib / pleroma / web / plugs / parsers / multipart.ex
diff --git a/lib/pleroma/web/plugs/parsers/multipart.ex b/lib/pleroma/web/plugs/parsers/multipart.ex
new file mode 100644 (file)
index 0000000..6b5ab6a
--- /dev/null
@@ -0,0 +1,21 @@
+defmodule Pleroma.Web.Plugs.Parsers.Multipart do
+  @multipart Plug.Parsers.MULTIPART
+
+  alias Pleroma.Config
+
+  def init(opts) do
+    opts
+  end
+
+  def parse(conn, "multipart", subtype, headers, opts) do
+    length = Config.get([:instance, :upload_limit])
+
+    opts = @multipart.init([length: length] ++ opts)
+
+    @multipart.parse(conn, "multipart", subtype, headers, opts)
+  end
+
+  def parse(conn, _type, _subtype, _headers, _opts) do
+    {:next, conn}
+  end
+end