Reputation: 41
We have a SharePoint site to allow users to upload attachments to document library. Sometimes they upload zip files, business area likes to know how many files are in the attached zip files.
Is there a way to achieve that through JavaScript or API?
Upvotes: 1
Views: 808
Reputation: 1889
It's possible to get files under a zip. You may have a look below JS lib:
And here are some demo:
BR
Upvotes: 1
Reputation: 407
Yes it is possible, check out this npm module for one example: https://www.npmjs.com/package/adm-zip This is node js. I don't think it will work as client side code, but I have never used the module. But as a proof of concept, and to point you in the general direction, this might help you on your way. Notably, it has millions of downloads.
ADM-ZIP is a pure JavaScript implementation for zip data compression for NodeJS.
const AdmZip = require('adm-zip');
// reading archives
const zip = new AdmZip("./my_file.zip");
const zipEntries = zip.getEntries(); // an array of ZipEntry records
const zipLength = zipEntries.length
Upvotes: 1