Skip to content

UnZip

Extracts the files inside an archive file into the database and returns an array containing file information.

1
myDocumentFiles.UnZip(id: string, separator?: string):Array<FileInfo>

Parameters

string id
    The ID of the archive file.

string separator optional
    The directory separator. Optional. The default value is "\".

Returns

An array of FileInfo objects representing the extracted files.

Remarks

This function is used to extract the contents of an archive file.

Each non-empty archive entry is saved as a standalone workflow file with application/octet-stream MIME type. Directory and empty entries are skipped, and extracted files are not attached to the source document.

Examples

Read the files of an uploaded archive

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var archiveId = $Xml.Evaluate('ImportArchive');

$Files.UnZip(archiveId, '/').forEach(function (file) {
    $Xml.AppendChild('Imports/Import', function (node) {
        node.SetValue('Name', file.Name);
        node.SetValue('File', file.Id);
    });
});

// the extracted files are stored separately, so the archive can be deleted
$Files.Delete(archiveId);

See Also