2

According to the tickets at Is it possible to send binary data with STOMP over WebSockets using Spring-WebSockets? 's answer it should be possible to send and receive files using spring-websockets.

Currently I'm converting the file to an ArrayBuffer and then sending it:

fileInput.addEventListener('change', function(e) {
                var file = fileInput.files[0];
                var reader = new FileReader();
                reader.readAsArrayBuffer(file);
                stompClient.send("/app/requests." + channelId + ".files", {}, reader.result);
            });

However as far as I can tell the controller doesn't receive the Bytearray in the messages payload.

@MessageMapping("requests.{channelId}.files")
    public void receiveFile(@DestinationVariable String channelId, Message<?> message) throws Exception {
        ...
    }

Could anyone please post a working example on how this should be done properly? Thank you

Community
  • 1
  • 1
DanielF
  • 37
  • 5

0 Answers0