files in chat messages
This commit is contained in:
SDE
2023-09-17 17:50:33 +03:00
parent 87b95f50fb
commit eebdd35ec8
4 changed files with 63 additions and 29 deletions

View File

@@ -124,12 +124,23 @@ class ChatConsumer(WebsocketConsumer):
def receive(self, text_data=None, bytes_data=None):
print(f'ws receive text_data = {text_data}')
import base64
from AuthApp.models import User
from .models import Message, MsgGroup
data = json.loads(text_data)
# if 'file' in data:
# file_Dict = json.loads(data['file'])
#
# f = open(f'chat_file_storage/{file_Dict["file_name"]}', 'wb+')
# head, content = file_Dict['file'].split(',')
# content = base64.b64decode(content)
# f.write(content)
# f.close()
sender = data['sender']
receiver = data['receiver']
sender_obj = User.objects.get(id=sender)