I am getting a zip file response from a HTTP GET request which contains two other files in it of extensions .log and .out. I am using zip.js to successfully read the data from the .log file but when I try to pass the text data, read from the .log file, as an argument to an event , I get the error :
"File Format is not recognized"
I am doing this on client-side javascript.
Here is my code :
var xhr = new XMLHttpRequest();
xhr.onload = function(e) {
var blobData = new Blob([this.response],{type : "application/zip"});
zip.createReader(new zip.BlobReader(blobData), function(zipReader){
zipReader.getEntries(function(entries){
entries[1].getData(new zip.TextWriter(), function(text){
console.log(text);
this.Emit("dataReady", {
data : text});
});
}.bind(this));
}.bind(this),this.onerror);
}.bind(this);
xhr.open("GET","path/to/url/file.zip",true);
xhr.setRequestHeader("Content-type","application/zip");
xhr.responseType = 'blob';
xhr.send();
The error I am getting is:
File format is not recognized.
Please advice as I am using zip.js and reading a zip file response from an http request for the first time.Thanks!