Finally, I solved the problem myself.
It was the client side that was to blame.
- In fact,
xhr.response is a JSON format, so it was between the double quotes "ChEKBFRlc3QQARkfhetRuB4JQA==" . I had to JSON. View my answer. enter code here - I deleted
xhr.responseType = "arraybuffer";
Here is my code now:
var ProtoBuf = dcodeIO.ProtoBuf; var xhr = ProtoBuf.Util.XHR(); xhr.open( /* method */ "GET", /* file */ "/XXXX/Protobuf/GetProtoData", /* async */ true ); // xhr.responseType = "arraybuffer"; <--- Removed xhr.onload = function (evt) { var testModelBuilder = ProtoBuf.loadProtoFile( "URL_TO_PROTO_FILE", "Container.proto").build("Container"); var msg = testModelBuilder.decode64(JSON.parse(xhr.response)); <-- Parse the response in JSON format console.log(msg); // Correctly decoded } xhr.send(null);
Guillaume
source share