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
05967472
Commit
05967472
authored
Nov 17, 2018
by
kaniini
Browse files
Merge branch 'feature/uploader-mdii' into 'develop'
Feature / MDII Uploader See merge request
pleroma/pleroma!454
parents
e4f57f89
59e079f6
Pipeline
#4526
passed with stages
in 7 minutes and 27 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
config/config.exs
View file @
05967472
...
...
@@ -23,6 +23,10 @@
public_endpoint:
"https://s3.amazonaws.com"
,
force_media_proxy:
false
config
:pleroma
,
Pleroma
.
Uploaders
.
MDII
,
cgi:
"https://mdii.sakura.ne.jp/mdii-post.cgi"
,
files:
"https://mdii.sakura.ne.jp"
config
:pleroma
,
:emoji
,
shortcode_globs:
[
"/emoji/custom/**/*.png"
]
config
:pleroma
,
:uri_schemes
,
...
...
lib/pleroma/uploaders/mdii.ex
0 → 100644
View file @
05967472
defmodule
Pleroma
.
Uploaders
.
MDII
do
alias
Pleroma
.
Config
@behaviour
Pleroma
.
Uploaders
.
Uploader
@httpoison
Application
.
get_env
(
:pleroma
,
:httpoison
)
def
put_file
(
name
,
uuid
,
path
,
content_type
,
should_dedupe
)
do
cgi
=
Pleroma
.
Config
.
get
([
Pleroma
.
Uploaders
.
MDII
,
:cgi
])
files
=
Pleroma
.
Config
.
get
([
Pleroma
.
Uploaders
.
MDII
,
:files
])
{
:ok
,
file_data
}
=
File
.
read
(
path
)
extension
=
String
.
split
(
name
,
"."
)
|>
List
.
last
()
query
=
"
#{
cgi
}
?
#{
extension
}
"
with
{
:ok
,
%{
status_code:
200
,
body:
body
}}
<-
@httpoison
.
post
(
query
,
file_data
)
do
File
.
rm!
(
path
)
remote_file_name
=
String
.
split
(
body
)
|>
List
.
first
()
public_url
=
"
#{
files
}
/
#{
remote_file_name
}
.
#{
extension
}
"
{
:ok
,
public_url
}
else
_
->
Pleroma
.
Uploaders
.
Local
.
put_file
(
name
,
uuid
,
path
,
content_type
,
should_dedupe
)
end
end
end
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