fix: 2MB size limit on profile picture upload

This commit is contained in:
AdrienLSH 2024-02-07 21:53:36 +01:00
parent cc4c09fd0d
commit a265c0bd19

View File

@ -56,7 +56,7 @@ class MyProfileViewSet(viewsets.ModelViewSet):
def perform_update(self, serializer, pk=None):
profile: ProfileModel = self.get_object()
avatar = self.request.data.get("file", None)
if (avatar is not None):
if (avatar is not None and avatar.size <= 2 * 1024 * 1024):
if (profile.avatar_url.name != "./profiles/static/avatars/default.avif"):
profile.avatar_url.storage.delete(profile.avatar_url.name)
profile.avatar_url = avatar