2018-08-29 01:32:24 +00:00
|
|
|
defmodule Pleroma.Uploaders.Swift do
|
|
|
|
@behaviour Pleroma.Uploaders.Uploader
|
|
|
|
|
2018-11-23 16:40:45 +00:00
|
|
|
def get_file(name) do
|
|
|
|
{:ok, {:url, Path.join([Pleroma.Config.get!([__MODULE__, :object_url]), name])}}
|
|
|
|
end
|
|
|
|
|
|
|
|
def put_file(name, uuid, tmp_path, content_type, _opts) do
|
2018-08-29 01:32:24 +00:00
|
|
|
{:ok, file_data} = File.read(tmp_path)
|
|
|
|
remote_name = "#{uuid}/#{name}"
|
|
|
|
|
|
|
|
Pleroma.Uploaders.Swift.Client.upload_file(remote_name, file_data, content_type)
|
|
|
|
end
|
|
|
|
end
|