1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Uploaders.Local do
6 @behaviour Pleroma.Uploaders.Uploader
10 {:ok, {:static_dir, upload_path()}}
14 def put_file(upload) do
16 case Enum.reverse(Path.split(upload.path)) do
21 path = Path.join([upload_path()] ++ Enum.reverse(folders))
26 result_file = Path.join(local_path, file)
28 if not File.exists?(result_file) do
29 File.cp!(upload.tempfile, result_file)
36 Pleroma.Config.get!([__MODULE__, :uploads])
40 def delete_file(path) do
46 {:error, posix_error} -> {:error, to_string(posix_error)}