I coded a web socket using Django channels and now want to add the possibility to send images over the chat (obviously it is a chat application).
What I did for now:
- The user picks an image (frontend)
- The user sends it to the backend (HTTP POST)
- I use Django signals (it is a listener for the database) to detect if there is a new message with an image appended
- I send the image back over the websocket
Following is the problem:
- It is slow (not too noticeable but quite slow)
- Sometimes it causes weird misbehavior
So now I thought about sending the image as a base64 and then sending it back directly so I never have any HTTP which can be helpful, because it is a little bit faster.
BUT: Base64 images are 20-30 percent bigger and I need to extract all the exif data in the frontend. Is there any possibility to send the images as a file over the websocket to the backend or if not is there a way to get around the quite greater size (20-30 percent), which is a problem because I cannot use too much bandwidth :/
How do other chat application solve this problem?