I am working on a project with Mozilla Europe. In this project, I use websocket by Worlize (server-side) and Mozilla (client side), Node.js to try to upload files from a client to a server.
My present goal is to send a arraybuffer
of the file to the server. Create the arraybuffer and send it is fine.
But my server tells me that arraybuffer
is a utf8 message and not a binary message.
Do I misunderstand something? If not, how can i correct that?
Client side:
reader = new FileReader();
reader.readAsArrayBuffer(file);
reader.onload = function(e) {
connection.send(e.target.result);
};
Server side:
ws.on('message', function(message,flags) {
if (!flags.binary) {
//some code
}
else {
console.log('It\'s a binary');
}
I try with Blob
too, same result. The binary part is invisible.
Gecko11.0 ArrayBuffer send and receive support for binary data has been implemented.
sending Binary data:
Recieving Binary Data:
Source: https://developer.mozilla.org/en/WebSockets/Writing_WebSocket_client_applications