MWAN001
MWAN001

Reputation: 41

Possible to use JavaScript or API to get the number of files in zip files

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

Answers (2)

Baker_Kong
Baker_Kong

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

ekrenzin
ekrenzin

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

Related Questions