addToArchive
Creates a .zip archive with the specified files and saves it in the file upload location. The archived files must also be stored in the file upload location.
IMPORTANT!
Make sure that the .zip file extension is defined in the
Make sure that the .zip file extension is defined in the
FileUploadWhiteList key in the Configuration Manager.Syntax
function addToArchive(archiveData: any): string
The archiveData object has the following structure:
{
'fileNames': [
{
'Name': '<in-archive file 1 name>',
'RealName': '<file 1 real name>'
},
{
'Name': '<in-archive file 2 name>',
'RealName': '<file 2 real name>'
},
...
],
'archiveName': '<archive name>',
'password': '<archive password>' //optional
}
| Parameter | Description |
|---|---|
fileNames
|
Array of JSON objects containing the archived files' names. |
Name
|
Name of the file as it will be saved inside the .zip archive. |
RealName
|
Unique internal ID of the source file (real name). |
archiveName
|
Name of the archive, including the .zip file extension. |
password optional |
Keyword used to password-protect the archive. |
Return Value
Returns a string containing the saved archive's real name.
Examples
In this example:
- We create an archive called JohnDoeDocumentation.zip containing the following files:
- JohnDoe_contract.pdf sourced from contract_6ed258eb-d609-4006-aee5-92be61477d4a.pdf.
- JohnDoe_contract_appendix.pdf sourced from contract_appendix_df7022c8-4fb3-4353-9fa8-bb2514e3a6ea.pdf.
- JohnDoe_GDPR_agreement.pdf sourced from GDPR_agreement_fd002212-7684-4ee1-82ae-ac4ece1e70ac.pdf.
- We display the archive's real name on screen. For details on how to display messages, see setMessage.
var archiveData = {
'fileNames': [
{
'Name': 'JohnDoe_contract.pdf',
'RealName': 'contract_6ed258eb-d609-4006-aee5-92be61477d4a.pdf'
},
{
'Name': 'JohnDoe_contract_appendix.pdf',
'RealName': 'contract_appendix_df7022c8-4fb3-4353-9fa8-bb2514e3a6ea.pdf'
},
{
'Name': 'JohnDoe_GDPR_agreement.pdf',
'RealName': 'GDPR_agreement_fd002212-7684-4ee1-82ae-ac4ece1e70ac.pdf'
}
],
'archiveName': 'JohnDoeDocumentation.zip',
};
setMessage('Customer documentation saved to ' + addToArchive(archiveData) + '.')