I want know how to send files through socket (socket.io) with node.js, this is for Phonegap mobile app.
1 Answer
I'm not sure if phonegap can use socket.io client javascript library, if yes, then it's easy. You can use Deliver.js as Chad suggested. It's based on utf8/base64.
Or you can refer to this How to Create a Resumable Video Uploader in Node.js. It's got a demo.
If you want to use native iOS library, take a look at this: socket.IO-objc, it's an iOS version of socket.io client library, can communicate with socket.io server quite well. You can build a similar file transfer logic based on this library.
2 Comments
Javier Gomez
Hello, i did a app with node.js and socket.io and works very well, but i did can't send files, for now i am thinking on get base4 of file, and make a chunks of 8bytes, then try to send chunk by chunk, with implementing a bucle for this.
Tony Chen
Just saw this: stackoverflow.com/questions/10738073/socket-io-phonegap, looks like PhoneGap can load socket.io client lib. So I think you can use delivery.js to send file. Or just build your own file sending logic.
socket.io send fileas my query, including a module designed to do exactly what you are asking for (delivery.js)