Convert Int8Array to byte[] javascript

女生的网名这么多〃 提交于 2019-12-06 03:49:46

问题


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?

来源:https://stackoverflow.com/questions/27861112/convert-int8array-to-byte-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!