extract

extract

Note: This function is applicable to all Zoho services. In Zoho Creator, this function can be applied only on files fetched using the invokeUrl task and not on the files fetched from Zoho Creator fields.

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,

ParameterData typeDescription
<variable>COLLECTIONVariable 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:"http://www.awitness.org/prophecy.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.
 {
  "prophecy\\hopelessly_idealistic.html":"prophecy\\hopelessly_idealistic.html",
  "prophecy\\yeshua_666.html":"prophecy\\yeshua_666.html",
  "prophecy\\tax_cut.html":"prophecy\\tax_cut.html",
  "prophecy\\war_in_heaven.html":"prophecy\\war_in_heaven.html",
 }

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");
 }

Related Links

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com