Commit b9f13abe authored by Elizabeth Myers's avatar Elizabeth Myers 💬
Browse files

Fix media upload

parent cfa82a94
......@@ -127,7 +127,10 @@ class FileUploader(ABC):
class MediaFileUploader(FileUploader):
def url_path(self, filename):
return f'media/{filename}'
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"}',
return dest_filename
return self.url_path(dest_filename)
def max_file_size(self):
......@@ -198,7 +201,10 @@ class MediaFileUploader(FileUploader):
class AvatarFileUploader(MediaFileUploader):
def url_path(self, filename):
return f'avatar/{filename}'
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'},
file_path = Path(conf.media_storage_path, filename)
file_path = Path(self.storage_path, filename)
if file_path.is_file():
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