我想批量上传zip文件中的简历并提取每份简历的内容 [英] I want to bulk upload the resumes in zip file and extract the content of each resume

查看:164
本文介绍了我想批量上传zip文件中的简历并提取每份简历的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用过jszip JavaScript库来解压缩zip文件。我还在javascript文件中的变量中获取了文件名,但是当我编写var name.asText()时无法读取该文件。它为我们提供了加密数据。



我尝试过:



我使用以下服务来提取并获取zip文件的内容。

.factory(extractAndParse,[$ q,函数($ q){

函数解压缩(zipfile){

调试器;

var dfd = $ q.defer();

var reader = new FileReader() ;



reader.onerror = dfd.reject.bind(dfd);

reader.onload = function(e){

调试器;

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 (新错误('package.json不存在'));

}

调试器;

console.log(file.asText());

返回dfd.resolve(file.asText());

};



reader.readAsArrayBuffer(zipfile);



返回dfd.promise;

}



函数extractAndParse(zipfile){

返回解压缩(zipfile)

// .then(JSON。解析);

}



返回extractAndParse;

}]);



现在它说.asText()不是函数。

我想读取文件的内容并放入角度范围内。

任何建议都将受到高度赞赏。

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.

推荐答案

q,功能(


q){

函数解压缩(zipfile){

调试器;

var dfd =
q) {
function unzip(zipfile) {
debugger;
var dfd =


q.defer();

var reader = new FileReader();



reader.onerror = dfd。 reject.bind(dfd);

reader.onload = function(e){

调试器;

if(!reader.result)dfd .reject(新错误(未知错误));



var zip = new JSZip(reader.result);



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







if(typeof file ==='undefined'){

dfd.reject(new error('package.json not exists'));

} $ / $
调试器;

console.log(file.asText());

返回dfd.resolve(file.asText());

};



reader.readAsArrayBuffer(zipfile);



返回dfd.promise;

}



函数extractAndParse(zipfile){

return unzip(zipfile)

// .then(JSON.parse);

}



return extractAn dParse;

}]);



现在它说.asText()不起作用。

我想要读取文件的内容并放入角度范围。

任何建议都将受到高度赞赏。
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.


这篇关于我想批量上传zip文件中的简历并提取每份简历的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆