I\'m trying to upload large files (at least 500MB, preferably up to a few GB) using the WebSocket API. The problem is that I can\'t figure out how to write \"send this slice
I believe the send() method is asynchronous which is why it will return immediately. To make it queue, you'd need the server to send a message back to the client after each slice is uploaded; the client can then decide whether it needs to send the next slice or a "upload complete" message back to the server.
This sort of thing would probably be easier using XMLHttpRequest(2); it has callback support built-in and is also more widely supported than the WebSocket API.