projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix admin api.
[akkoma]
/
lib
/
pleroma
/
upload.ex
diff --git
a/lib/pleroma/upload.ex
b/lib/pleroma/upload.ex
index 2293ff54e4fab1d3604771980207fab48c3925d9..238630bf357759762f62eddbf95bc0fab296a0b1 100644
(file)
--- a/
lib/pleroma/upload.ex
+++ b/
lib/pleroma/upload.ex
@@
-1,9
+1,6
@@
defmodule Pleroma.Upload do
alias Ecto.UUID
defmodule Pleroma.Upload do
alias Ecto.UUID
- @storage_backend Application.get_env(:pleroma, Pleroma.Upload)
- |> Keyword.fetch!(:uploader)
-
def check_file_size(path, nil), do: true
def check_file_size(path, size_limit) do
def check_file_size(path, nil), do: true
def check_file_size(path, size_limit) do
@@
-21,8
+18,7
@@
defmodule Pleroma.Upload do
true <- check_file_size(file.path, size_limit) do
strip_exif_data(content_type, file.path)
true <- check_file_size(file.path, size_limit) do
strip_exif_data(content_type, file.path)
- {:ok, url_path} =
- @storage_backend.put_file(name, uuid, file.path, content_type, should_dedupe)
+ {:ok, url_path} = uploader().put_file(name, uuid, file.path, content_type, should_dedupe)
%{
"type" => "Document",
%{
"type" => "Document",
@@
-57,8
+53,7
@@
defmodule Pleroma.Upload do
content_type
)
content_type
)
- {:ok, url_path} =
- @storage_backend.put_file(name, uuid, tmp_path, content_type, should_dedupe)
+ {:ok, url_path} = uploader().put_file(name, uuid, tmp_path, content_type, should_dedupe)
%{
"type" => "Image",
%{
"type" => "Image",
@@
-167,7
+162,13
@@
defmodule Pleroma.Upload do
"audio/mpeg"
<<0x4F, 0x67, 0x67, 0x53, 0x00, 0x02, 0x00, 0x00>> ->
"audio/mpeg"
<<0x4F, 0x67, 0x67, 0x53, 0x00, 0x02, 0x00, 0x00>> ->
- "audio/ogg"
+ case IO.binread(f, 27) do
+ <<_::size(160), 0x80, 0x74, 0x68, 0x65, 0x6F, 0x72, 0x61>> ->
+ "video/ogg"
+
+ _ ->
+ "audio/ogg"
+ end
<<0x52, 0x49, 0x46, 0x46, _, _, _, _>> ->
"audio/wav"
<<0x52, 0x49, 0x46, 0x46, _, _, _, _>> ->
"audio/wav"
@@
-182,4
+183,8
@@
defmodule Pleroma.Upload do
_e -> "application/octet-stream"
end
end
_e -> "application/octet-stream"
end
end
+
+ defp uploader() do
+ Pleroma.Config.get!([Pleroma.Upload, :uploader])
+ end
end
end