Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have used used the jszip JavaScript library to unzip the zip file. I also got the files name in the variable in javascript file but unable to read the file while I wrote the var name.asText(). It gives us encrypted data.

What I have tried:

I have used the below service to extract and get the content of zip file.
.factory("extractAndParse", ["$q", function ($q) {
function unzip(zipfile) {
debugger;
var dfd = $q.defer();
var reader = new FileReader();

reader.onerror = dfd.reject.bind(dfd);
reader.onload = function (e) {
debugger;
if (!reader.result) dfd.reject(new Error("Unknown error"));

var zip = new JSZip(reader.result);

var file = zip.files['CVLIST/Rabin.docx'];



if(typeof file === 'undefined') {
dfd.reject(new Error('package.json does not exist'));
}
debugger;
console.log(file.asText());
return dfd.resolve(file.asText());
};

reader.readAsArrayBuffer(zipfile);

return dfd.promise;
}

function extractAndParse (zipfile) {
return unzip(zipfile)
// .then(JSON.parse);
}

return extractAndParse;
}]);

Now it says .asText() is not function.
I want read the content of the files and put in the scope of the angular.
Any suggestions will be highly appreciated.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900