Commit 0df558a6 authored by Thurloat's avatar Thurloat

cleaning up a bit.

parent 709816a0
......@@ -11,7 +11,7 @@ config :pleroma, ecto_repos: [Pleroma.Repo]
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,
......
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 @@ defmodule Pleroma.Upload 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 @@ defmodule Pleroma.Upload 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)
......
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)
......
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 @@ defmodule Pleroma.Uploaders.S3 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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment