summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2020-08-31 20:31:21 +0400
committerEgor Kislitsyn <egor@kislitsyn.com>2020-10-07 18:34:28 +0400
commitbe42ab70dc9538df54ac6f30ee123666223b7287 (patch)
tree8d191ec1529c655f2cdd4195248b21aa85cb0bb9 /lib
parentc82f9129592553718be4bd4712a2b1848dd0a447 (diff)
downloadpleroma-be42ab70dc9538df54ac6f30ee123666223b7287.tar.gz
pleroma-be42ab70dc9538df54ac6f30ee123666223b7287.zip
Add backup upload
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/export.ex20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/pleroma/export.ex b/lib/pleroma/export.ex
index 45b8ce749..b84eccd78 100644
--- a/lib/pleroma/export.ex
+++ b/lib/pleroma/export.ex
@@ -22,7 +22,25 @@ defmodule Pleroma.Export do
:ok <- bookmarks(path, user),
{:ok, zip_path} <- :zip.create('#{path}.zip', @files, cwd: path),
{:ok, _} <- File.rm_rf(path) do
- {:ok, zip_path}
+ {:ok, :binary.list_to_bin(zip_path)}
+ end
+ end
+
+ def upload(zip_path) do
+ uploader = Pleroma.Config.get([Pleroma.Upload, :uploader])
+ file_name = zip_path |> String.split("/") |> List.last()
+ id = Ecto.UUID.generate()
+
+ upload = %Pleroma.Upload{
+ id: id,
+ name: file_name,
+ tempfile: zip_path,
+ content_type: "application/zip",
+ path: id <> "/" <> file_name
+ }
+
+ with :ok <- uploader.put_file(upload), :ok <- File.rm(zip_path) do
+ {:ok, upload}
end
end