We currently have a project in android and company wants to do some parts on server. Server side code in with Node JS. The thing I want to do looks very simple but I am stuck on that.
We have a long byte array which is compressed, in the android project I have his code that works fine and decompress the byte array. I want to do same in Node JS but I got the error incorrect data check
.
public byte[] decompressBytes(byte[] compressedBytes) {
try {
Inflater decompresser = new Inflater();
decompresser.setInput(compressedBytes);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buf = new byte[2048];
while(!decompresser.finished()) {
int cnt = decompresser.inflate(buf);
if(cnt <= 0) {
break;
}
bos.write(buf, 0, cnt);
}
bos.close();
return bos.toByteArray();
} catch (Exception var6) {
return new byte[0];
}
}
Here is the code I wrote form the documents of Pako
but as I told it returns error.
function decompress(data, callback) {
var response = '';
var pako = require('pako');
try {
response = pako.inflate(actData);
console.log("response : " + response);
callback('', response);
} catch (err) {
console.log(err);
callback(err, '');
}
}
The inputs are exactly same byte array. Any help would be appreciated.