platform/web/views/profile_photo.py
Administrator 9e7fc7b4c1 initial
2023-09-23 16:13:11 +03:00

18 lines
545 B
Python

from django.http import HttpResponse
from BaseLib.BaseView import BaseView
from BaseLib.minio import minio_client
class ProfilePhoto(BaseView):
required_login = True
endpoint = "profile_photo"
def get(self):
profile_photo_bytes = minio_client.get_object(f"profile_photos/{self.request.GET['id']}")
if profile_photo_bytes == b"":
profile_photo_bytes = open("content/empty_profile_photo.jpg", "rb").read()
return HttpResponse(
profile_photo_bytes, content_type="image/jpg"
)