我正在使用JSZip提取zip文件,具体步骤如下:
jszip.loadAsync(zipFile)
['then'](function(zip) {
return bluebird.map(Object.keys(zip.files), function (filename) {
// converts the compressed file to a string of its contents
return zip.files[filename].async('string').then(function (fileData) {
// fileData is a string of the contents
})
})
})
然而,这种提取的输出结果是文件内容字符串数组。我想知道是否有可能将文件对象数组作为输出结果,因为我之后需要使用文件对象。
我尝试过:
new File(fileData.split('\n'), filename)
但它会丢失原始文件格式。有什么建议吗?
return new File([fileData], filename)
。 - tgreen