Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

List Zip file content with ZipFile

Avatar

Level 6

Hi,

How to list the content of a ZIP file with ZipFile?

In the documentation, we can only extract a file if we know its name (see ZipFile.getEntry(name) in https://docs.campaign.adobe.com/doc/AC/en/jsapi/c-ZipFile.html ).

How can we list the files inside? Or extract the first file? We tried ZipFile.entries, ZipFile.getEntries(), ZipFile[0] with no luck

Example:

var zip = new ZipFile(vars.filename);

logInfo(zip); // [object ZipFile]

logInfo(zip.open()); // function open() { [native code] }

logInfo(zip); // [object ZipFile]

logInfo(JSON.stringify(zip)); // {}

for(var prop in zip){

  logInfo(prop, ':', zip[prop]); // fileCount : 1

}

logInfo(zip.getEntry('abc.zip')); // OK, but what if the file got an autogenerated timestapm

ZIP file:

2019-01-17_110455_screen_2.jpg

At the moment we're using linux commands but this is somewhat a hack:

execCommand('unzip -j '+vars.filename+' -d target_directory');

Thank you

Florian

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

I've always just used execCommand(). Interesting doc link, that forms section looks like something new.

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

I've always just used execCommand(). Interesting doc link, that forms section looks like something new.