diff options
author | Rachel Fae Fox <allisonthefox@gmail.com> | 2019-09-23 20:38:53 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-09-23 20:38:53 +0000 |
commit | 63af6951fa42429d0a02861d5ad1afdd053864cf (patch) | |
tree | ab6ce289d6cedbb273832c7e56d273990b537c38 /lib | |
parent | ad2ffd7ef1cbb8afff6ecee2cbda79414a12fbaa (diff) | |
download | pleroma-63af6951fa42429d0a02861d5ad1afdd053864cf.tar.gz |
add tunable for stream uploads, as needed for jortage to work.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/uploaders/s3.ex | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/pleroma/uploaders/s3.ex b/lib/pleroma/uploaders/s3.ex index 8c353bed3..9876b6398 100644 --- a/lib/pleroma/uploaders/s3.ex +++ b/lib/pleroma/uploaders/s3.ex @@ -38,16 +38,26 @@ defmodule Pleroma.Uploaders.S3 do def put_file(%Pleroma.Upload{} = upload) do config = Config.get([__MODULE__]) bucket = Keyword.get(config, :bucket) + streaming = Keyword.get(config, :streaming_enabled) s3_name = strict_encode(upload.path) op = - upload.tempfile - |> ExAws.S3.Upload.stream_file() - |> ExAws.S3.upload(bucket, s3_name, [ - {:acl, :public_read}, - {:content_type, upload.content_type} - ]) + if streaming do + upload.tempfile + |> ExAws.S3.Upload.stream_file() + |> ExAws.S3.upload(bucket, s3_name, [ + {:acl, :public_read}, + {:content_type, upload.content_type} + ]) + else + {:ok, file_data} = File.read(upload.tempfile) + + ExAws.S3.put_object(bucket, s3_name, file_data, [ + {:acl, :public_read}, + {:content_type, upload.content_type} + ]) + end case ExAws.request(op) do {:ok, _} -> |