5

I am trying to pass an Int8Array, which is created from an array buffer to a java method via DWR, which accepts it as a byte[] parameter.

Javascript :

   uploadFiles: function(eve) {
        var fileContent = null;

        for(var i = 0; i < this.filesToBeUploaded.length; i++){
            var reader = new FileReader();
            reader.onload = (function(fileToBeUploaded) {
                return function(e) {
                    file = e.target.result;
                    var view = new Int8Array(file);
                    // fileContent object contains the content of the read file
                };
            })(this.filesToBeUploaded[i]);

            reader.readAsArrayBuffer(this.filesToBeUploaded[i]);
        }            
    }

I want the contents of view to be passed to this method -

public boolean uploadFile(String fileName, byte[] fileContent) {}

DWR seems to be unable to marshal the view object to the java layer. Is there any setting I am missing?

user4020527
  • 1
  • 8
  • 20
bub
  • 657
  • 1
  • 9
  • 18
  • 1
    The ArrayBuffer (file) is the actual byte-buffer (Uint8Array is just a view on top of it). Have you tried just passing that directly? –  Mar 30 '15 at 09:21

0 Answers0