cleaning up a bit.

This commit is contained in:
Thurloat 2018-08-27 22:45:53 -03:00
parent 709816a0f8
commit 0df558a6a5
5 changed files with 12 additions and 9 deletions

View file

@ -11,7 +11,7 @@
config :pleroma, Pleroma.Repo, types: Pleroma.PostgresTypes
config :pleroma, Pleroma.Upload,
uploader: Pleroma.Uploaders.Local
uploader: Pleroma.Uploaders.Local,
strip_exif: false
config :pleroma, Pleroma.Uploaders.Local,

View file

@ -1,6 +1,5 @@
defmodule Pleroma.Upload do
alias Ecto.UUID
alias Pleroma.Web
def store(%Plug.Upload{} = file, should_dedupe) do
settings = Application.get_env(:pleroma, Pleroma.Upload)
@ -26,7 +25,7 @@ def store(%Plug.Upload{} = file, should_dedupe) do
"name" => name
}
end
"""
# XXX: does this code actually work? i am skeptical. --kaniini
def store(%{"img" => "data:image/" <> image_data}, should_dedupe) do
settings = Application.get_env(:pleroma, Pleroma.Upload)
@ -88,11 +87,12 @@ def store(%{"img" => "data:image/" <> image_data}, should_dedupe) do
"name" => name
}
end
"""
def strip_exif_data(content_type, file) do
settings = Application.get_env(:pleroma, Pleroma.Upload)
do_strip = Keyword.fetch!(settings, :strip_exif)
[filetype, ext] = String.split(content_type, "/")
[filetype, _ext] = String.split(content_type, "/")
if filetype == "image" and do_strip == true do
Mogrify.open(file) |> Mogrify.custom("strip") |> Mogrify.save(in_place: true)

View file

@ -1,7 +1,10 @@
defmodule Pleroma.Uploaders.Local do
def put_file(name, uuid, file, content_type) do
upload_path = get_upload_path(uuid, should_dedupe)
alias Pleroma.Web
def put_file(name, uuid, file, _content_type, should_dedupe) do
upload_folder = get_upload_path(uuid, should_dedupe)
url_path = get_url(name, uuid, should_dedupe)
File.mkdir_p!(upload_folder)

View file

@ -1,6 +1,6 @@
defmodule Pleroma.Uploaders.S3 do
def put_file(name, uuid, path, content_type) do
def put_file(name, uuid, path, content_type, _should_dedupe) do
settings = Application.get_env(:pleroma, Pleroma.Uploaders.S3)
bucket = Keyword.fetch!(settings, :bucket)
@ -12,7 +12,7 @@ def put_file(name, uuid, path, content_type) do
s3_name = "#{uuid}/#{name}"
{:ok, result} =
{:ok, _} =
ExAws.S3.put_object(bucket, s3_name, file_data, [
{:acl, :public_read},
{:content_type, content_type}

View file

@ -11,7 +11,7 @@ defmodule Pleroma.Web.Endpoint do
#
# You should set gzip to true if you are running phoenix.digest
# when deploying your static files in production.
plug(Plug.Static, at: "/media", from: Pleroma.Upload.upload_path(), gzip: false)
plug(Plug.Static, at: "/media", from: Pleroma.Uploaders.Local.upload_path(), gzip: false)
plug(
Plug.Static,