Convert Int8Array to byte[] javascript

2019-04-08 17:48发布

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?

0条回答
登录 后发表回答