cleaning up a bit.
This commit is contained in:
parent
709816a0f8
commit
0df558a6a5
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue