3

I want know how to send files through socket (socket.io) with node.js, this is for Phonegap mobile app.

3
  • 4
    Did you even try googling this? I saw a bunch of promising results with socket.io send file as my query, including a module designed to do exactly what you are asking for (delivery.js) Commented Sep 22, 2013 at 5:46
  • Please be aware that files are sent text-encoded and not in binary form. Commented Sep 22, 2013 at 14:10
  • Although socket.io doesn't support sending binary data, it can send string in any charset. With FileReader, you can read binary into strings and sending it directly without encoding it to base64. (actually it's in ISO/IEC 8859-1 latin). You can do with native iOS library as well. Commented Sep 22, 2013 at 15:18

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.