extract
Table of Contents
Overview
The extract function extracts the contents of a zipped file fetched from the cloud.
Note:
- The extracted response is a collection with the name of the extracted file as the key and the corresponding file object as the value.
- If the file used for extraction is not a zip or if the zip is empty, an empty collection is returned
- This function cannot extract content from a zip file that is protected with password.
- In Zoho Creator, this function can return response of size upto 500KB and in other Zoho services that support Deluge, it can return upto 3 MB. If the size exceeds the limit, the function throws an error.
Return Type
Syntax
<variable> = <zip_file>.extract();
where,
Parameter | Data type | Description |
<variable> | COLLECTION | Variable which will contain the extracted files. |
<zip_file> | FILE OBJECT | The zip file whose contents need to be retrieved. |
Examples
The below example fetches a zip file from cloud and extracts the individual files inside it.
zip = invokeUrl [ url :"https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-zip-file.zip" type : GET ]; file_collection = zip.extract(); // The response will be a collection like the below. It may appear that the key and value are the same but the key is TEXT type and the value is a FILE OBJECT. { "sample.txt":"sample.txt" }
Below is a sample snippet which uploads the extracted files from a zip into a workdrive folder.
for each file in file_collection { zoho.workdrive.uploadFile(file,"imhze9e3df8XXXXXXXXXd44ff2c",file.getFileName(),true,"work"); }