Update Dockerfile with labels. Update gitlab-ci for registry usage
[akkoma] / lib / pleroma / uploaders / local.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Uploaders.Local do
6 @behaviour Pleroma.Uploaders.Uploader
7
8 def get_file(_) do
9 {:ok, {:static_dir, upload_path()}}
10 end
11
12 def put_file(upload) do
13 {local_path, file} =
14 case Enum.reverse(Path.split(upload.path)) do
15 [file] ->
16 {upload_path(), file}
17
18 [file | folders] ->
19 path = Path.join([upload_path()] ++ Enum.reverse(folders))
20 File.mkdir_p!(path)
21 {path, file}
22 end
23
24 result_file = Path.join(local_path, file)
25
26 if not File.exists?(result_file) do
27 File.cp!(upload.tempfile, result_file)
28 end
29
30 :ok
31 end
32
33 def upload_path do
34 Pleroma.Config.get!([__MODULE__, :uploads])
35 end
36 end