Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
8d2d7a88
Commit
8d2d7a88
authored
Aug 28, 2018
by
Thurloat
Browse files
Implement uploader behaviour
run formatter <#
parent
0df558a6
Changes
5
Hide whitespace changes
Inline
Side-by-side
config/config.exs
View file @
8d2d7a88
...
...
@@ -14,11 +14,9 @@
uploader:
Pleroma
.
Uploaders
.
Local
,
strip_exif:
false
config
:pleroma
,
Pleroma
.
Uploaders
.
Local
,
uploads:
"uploads"
config
:pleroma
,
Pleroma
.
Uploaders
.
Local
,
uploads:
"uploads"
config
:pleroma
,
Pleroma
.
Uploaders
.
S3
,
s3_bucket:
nil
config
:pleroma
,
Pleroma
.
Uploaders
.
S3
,
s3_bucket:
nil
config
:pleroma
,
:emoji
,
shortcode_globs:
[
"/emoji/custom/**/*.png"
]
...
...
lib/pleroma/upload.ex
View file @
8d2d7a88
defmodule
Pleroma
.
Upload
do
alias
Ecto
.
UUID
def
store
(%
Plug
.
Upload
{}
=
file
,
should_dedupe
)
do
settings
=
Application
.
get_env
(
:pleroma
,
Pleroma
.
Upload
)
storage_backend
=
Keyword
.
fetch!
(
settings
,
:storage_backend
)
@storage_backend
Application
.
get_env
(
:pleroma
,
Pleroma
.
Upload
)
|>
Keyword
.
fetch!
(
:uploader
)
def
store
(%
Plug
.
Upload
{}
=
file
,
should_dedupe
)
do
content_type
=
get_content_type
(
file
.
path
)
uuid
=
get_uuid
(
file
,
should_dedupe
)
name
=
get_name
(
file
,
uuid
,
content_type
,
should_dedupe
)
strip_exif_data
(
content_type
,
file
.
path
)
url_path
=
storage_backend
.
put_file
(
name
,
uuid
,
content_type
)
url_path
=
@
storage_backend
.
put_file
(
name
,
uuid
,
file
,
content_type
,
should_dedupe
)
%{
"type"
=>
"Document"
,
...
...
@@ -25,6 +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
...
...
lib/pleroma/uploaders/local.ex
View file @
8d2d7a88
defmodule
Pleroma
.
Uploaders
.
Local
do
@behaviour
Pleroma
.
Uploaders
.
Uploader
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
)
...
...
lib/pleroma/uploaders/s3.ex
View file @
8d2d7a88
defmodule
Pleroma
.
Uploaders
.
S3
do
@behaviour
Pleroma
.
Uploaders
.
Uploader
def
put_file
(
name
,
uuid
,
path
,
content_type
,
_should_dedupe
)
do
settings
=
Application
.
get_env
(
:pleroma
,
Pleroma
.
Uploaders
.
S3
)
bucket
=
Keyword
.
fetch!
(
settings
,
:bucket
)
public_endpoint
=
Keyword
.
fetch!
(
settings
,
:public_endpoint
)
...
...
lib/pleroma/uploaders/swift.ex
View file @
8d2d7a88
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment