is it possible to send files from socket.io ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

is it possible to send files from socket.io ?

if it is possible, is it a good idea to do so ? or should i just rely on rest

26th Aug 2020, 4:50 PM
Rei
Rei - avatar
4 Answers
26th Aug 2020, 8:55 PM
Plaban Kr. Mondal
Plaban Kr. Mondal - avatar
+ 5
Rei As others have answered... yes... Socket.io supports the ability to transfer files. Whether it's a good idea or not will depend on your specific use case, expected frequency of uploads, expected size of files, whether or not you're supporting mobile devices as clients, etc. For simple scenarios involving periodic upload of small files, the implementation is rather straight forward. However, in cases, where you'll need to upload larger files, you'll want to use a NodeJS middleware called Multer for multipart/form-data support to send chunks of your file at a time. I'm including a few links I've vetted that should help you figure this out. ---- Socket.io File Upload -- https://medium.com/@Mewsse/file-upload-with-socket-io-9d2d1229494 https://docs.feathersjs.com/cookbook/express/file-uploading.html https://blog.feathersjs.com/http-vs-websockets-a-performance-comparison-da2533f13a77 ---- Understanding Socket.io -- https://hpbn.co/websocket/ https://www.ably.io/concepts/socketio
26th Aug 2020, 11:41 PM
David Carroll
David Carroll - avatar
+ 1
Yes!! socket.io has binary support
26th Aug 2020, 8:55 PM
Plaban Kr. Mondal
Plaban Kr. Mondal - avatar
0
oooh thank you! its so hard to navigate the socket.io docs in mobile
26th Aug 2020, 8:59 PM
Rei
Rei - avatar