Note that there are some explanatory texts on larger screens.

plurals
  1. POExtJS: Send file to a socket server
    primarykey
    data
    text
    <p>I'm using ExtJS 4.1.1 for my client app. I need to upload files to a socket server. I know I can use the WebSocket extension described <a href="https://github.com/wilk/ExtJS-WebSocket/blob/master/README.md" rel="nofollow">here</a> to send messages to the socket server. But I'm not sure whether this can work with files. </p> <p>I'll appreciate advice from anyone who have been faced with such a task before. It doesn't have to be done using the ExtJS WebSocket extension, but it has to be done using ExtJS on the client side. I'm using Netty for my socket server, but I think this is immaterial here.</p> <p><strong>UPDATE:</strong></p> <p>Following @Ee-P's recommendation, I've tried using <a href="https://github.com/vincentdieltiens/WebSocketFileTransfer" rel="nofollow">this extension</a>. However, that extension throws the exception <code>Uncaught TypeError: Cannot read property 'size' of undefined</code>. I can receive the file details on the server side, but I'm not sure how to access the file itself on the server side. I'm not sure whether the actual file is sent or whether it's just the details of the files. @Ee-P mentioned a wrapper class; all I've done is include the JS file and Mootools classes. And then, in my code, I have:</p> <pre><code>if(!WebSocketFileTransfer.supported()) { console.log('WebSocket File Transfer is not fully supported by your browser.'); return; } var transfer = new WebSocketFileTransfer({ url: 'ws://localhost:8087/ws', file: file, blockSize: 1024, type: WebSocketFileTransfer.binarySupported() ? 'binary' : 'base64', type: 'binary', progress: function(event) { console.log('File upload in progress'); }, success: function(event) { console.log('File successfully uploaded.'); } }); transfer.start(); </code></pre> <p>Any idea about what I may be doing wrong or alternatives will be appreciated very much.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload