function loadFileAsBinary()
{
var fileToLoad = document.getElementById("fileToLoad").files[0];
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
var textFromFileLoaded = fileLoadedEvent.target.result;
var rs = textFromFileLoaded;
var charData = rs.split('').map(function(x){return x.charCodeAt(0);});
console.log(charData);
var bindata = new Uint8Array(charData);
console.log(bindata);
var plain = pako.inflate(bindata, {to: 'string' });
var strData = String.fromCharCode.apply(null, new Uint16Array(plain));
document.getElementById("inputTextToSave").value = strData;
};
fileReader.readAsBinaryString(fileToLoad);
}
I want to inflate upload file but this function gives an error:
Uncaught incorrect header check
I was able to solve the same issue by using
r.readAsArrayBuffer(f);
andpako.inflate(new Uint8Array( e.target.result ) , {"to":"string"})
Here my code: