Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
DCP project
DCPv4
Commits
b9f13abe
Commit
b9f13abe
authored
Apr 22, 2022
by
Elizabeth Myers
💬
Browse files
Fix media upload
parent
cfa82a94
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
dcp/webserver/media.py
dcp/webserver/media.py
+10
-4
No files found.
dcp/webserver/media.py
View file @
b9f13abe
...
...
@@ -127,7 +127,10 @@ class FileUploader(ABC):
class
MediaFileUploader
(
FileUploader
):
@
staticmethod
def
url_path
(
self
,
filename
):
return
f
'media/
{
filename
}
'
@
property
def
storage_path
(
self
):
return
Path
(
conf
.
media_storage_path
,
'media'
)
...
...
@@ -163,7 +166,7 @@ class MediaFileUploader(FileUploader):
raise
web
.
HTTPBadRequest
(
text
=
'{"reason": "Malformed file"}'
,
content_type
=
'application/json'
)
return
dest_filename
return
self
.
url_path
(
dest_filename
)
@
property
def
max_file_size
(
self
):
...
...
@@ -198,7 +201,10 @@ class MediaFileUploader(FileUploader):
class
AvatarFileUploader
(
MediaFileUploader
):
@
staticmethod
def
url_path
(
self
,
filename
):
return
f
'avatar/
{
filename
}
'
@
property
def
storage_path
(
self
):
return
Path
(
conf
.
media_storage_path
,
'avatar'
)
...
...
@@ -292,7 +298,7 @@ async def avatar_delete_handler(request):
return
web
.
json_response
({
'reason'
:
'Bad file path'
},
status
=
400
)
file_path
=
Path
(
conf
.
media_
storage_path
,
filename
)
file_path
=
Path
(
self
.
storage_path
,
filename
)
if
file_path
.
is_file
():
file_path
.
unlink
()
else
:
...
...
Write
Preview
Markdown
is supported
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