I am buidling an App using Golang on server side and ReactNative/Node.js on client side.
A part of my app is to upload a video from the client to the server and to receive a video back (up to 100Mb).
As this is a bidirectionnal talk, I decided to use Websockets. This allow me to authenticate the user only once with its JWT Token and to keep the communication open up to the point where the client is uploading his video and receiving an other one in exchange.
Right now, I am at the point where I have to upload and download a video on both sides. All the communicatio has been in JSON so far. The video can be sent like this:
//After a few messages
{ "type": "sending_file", "sha2": `checksumofthevideo`}
{ "type":"video_chunk", "id": 1, data=`someverylongbytesofdata `}
{ "type":"video_chunk", "id": 2, data=`someverylongbytesofdata `}
{ "type":"video_chunk", "id": 3, data=`someverylongbytesofdata `}
The server, at the end, concatenates and writes all the bytes into a file then verify the checksum to make sure it is correct.
I am concerned about the effectiveness of this approach. I read that I should have used POST instead, allowing a much easier conversation and big files handling with the server.
Also Websockets are great for being used in a browser but in this case, I am using directly a node.js server on the client side so I guess this is lowering the advantage of the websocket.
I am having a really hard time to decide which one (REST vs Websocket) to use. I would appreciate any help about this, thanks!