can we send any kind of data (image, PDF, audio,video ) any size
please give one generic example that explain how to send file on socket
this example app records audio in the browser and then sends it to the server in binary chunks.
how to send local file stored on disk ( image , pdf , epub, mobi ) to chat
should i convert them to blob , arraybuffer , is there any documentation
This depends on the client that you are using. I assume you want to do this through the JavaScript client? You can emit ArrayBuffer or Blob, both are received as a bytes object in the server.
when i am sending blob to server i am able print content directly to cmd,
but when i am sending it back to client using emit() it is converted to ArrayBuffer(2563)
[[Int8Array]]
:
Int8Array(2563) [100, 105, 115, 116, 114, 105, 98, 117, 116, 105, 111, 110, 32, 118, 115, 32, 118, 97, 114, 97, 98, 108, 105, 116, 121, 32, 32, 111, 114, 32, 115, 116, 97, 110, 100, 97, 114, 100, 32, 100, 101, 118, 105, 97, 116, 105, 111, 110, 13, 10, 13, 10, 13, 10, 115, 99, 97, 108, 101, 32, 111, 102, 32, 115, 99, 97, 116, 116, 101, 114, 32, 112, 108, 111, 116, 13, 10, 108, 105, 110, 110, 101, 114, 32, 112, 97, 116, 116, 101, 114, 32, 111, 102, 32, 108, 105, 110, 101, 32, 105, 鈥
[[Uint8Array]]
:
Uint8Array(2563) [100, 105, 115, 116, 114, 105, 98, 117, 116, 105, 111, 110, 32, 118, 115, 32, 118, 97, 114, 97, 98, 108, 105, 116, 121, 32, 32, 111, 114, 32, 115, 116, 97, 110, 100, 97, 114, 100, 32, 100, 101, 118, 105, 97, 116, 105, 111, 110, 13, 10, 13, 10, 13, 10, 115, 99, 97, 108, 101, 32, 111, 102, 32, 115, 99, 97, 116, 116, 101, 114, 32, 112, 108, 111, 116, 13, 10, 108, 105, 110, 110, 101, 114, 32, 112, 97, 116, 116, 101, 114, 32, 111, 102, 32, 108, 105, 110, 101, 32, 105, 鈥
byteLength
:
(...)
how to deal with this
complete code on js is here
https://gist.github.com/rupesh2017/89b20c7757641efc51b060efe4fd6bb2
This is really outside of the server's control. There is only one way to send binary packets, each client and each server decide how to represent those binary payloads. In the server, they are presented as bytes.
Most helpful comment
this example app records audio in the browser and then sends it to the server in binary chunks.