Hello, I wonder if it is somehow possible to emit some file\data from the JS client to the Flask-SocketIO server?
I need to send audio data recorded from the browser along with some other regular text\json data.
It is possible with socketio? How should I approach it? Or should I rely on ajax and post stuff rather?
Thanks!
You can send binary data, that's supported. Even more, you can combine binary and JSON data in one message. So for example, you could send something like this:
socket.emit('recording', {'audio_data': binary_data, 'metadata': {'channels': 2, 'rate': 44100}});
For the server, I recommend you use Python 3, as that will make it easier to work with and differentiating between binary and text data.
But, just worth mentioning, it looks like there's a limit to how much data you can send with one emit, so large files should be split into multiple chunks. I'm not entirely sure about this, though
Most helpful comment
You can send binary data, that's supported. Even more, you can combine binary and JSON data in one message. So for example, you could send something like this:
For the server, I recommend you use Python 3, as that will make it easier to work with and differentiating between binary and text data.