How to unzip a file of remote server in Apigee Integration?

I am trying to upzip a file which is placed in a remote server. I tried to do it with python in cloud function. But Apigee is not able to read/write files, Its only deals with content of the file. And I am not aware of other options, how I can archive my requirement.

Steps I followed: PFA33224411

0 2 228
2 REPLIES 2

Former Community Member
Not applicable

In Cloud Functions I see you are setting the variable "output". Have you declared such a variable in Integration as an output variable? If yes, what type have you declared it as? You might have to declare it as a string.

One of the concepts that is important to understand in using the SFTP connection with Integration is the following.

The Connector will just read or write the file to or from the Contents variable (which is a property or element in the ConnectorInputPayload or the ConnectorOutputPayload).  What this means, practically speaking, is that the file contents are read into System Memory and are available to cloud functions as a variable.  Once you have the contents in Cloud Functions as a variable, you can use libraries available for that language to transform the data, like compression or encryption, encoding/decoding, etc...  

Let's consider a case where you want to download a file from and SFTP server, compress it, and then upload it back to the same SFTP server with a new file name (with a .zip extension or something).  These are the major logical steps...you may need some additional mapping steps, etc... 

Step 1 - set up variables for reading the file and use the SFTP Connection - Action - Download.  Create a variable called compressedOutput in integration (to receive the cloud functions output).

Step 2 - Call Cloud Function to compress the connectorOutputPayload[x].Contents if download was successful, and then don't forget to base64 encode the compressed output.  You can use the variable.get operation in Cloud functions to retrieve the payload from an Integration Variable

Step 3 - Set the integration variable called compressedOutput in Functions to receive the compressed and encoded content. Use the compressedOutput.set operation

Step 4 - Data mapper - map the variable from functions into the ConnectorInputPayload.Content.  Set up variables for the new name, filepath, etc...

Step 5 - Use the SFTP Connection - Action - Upload to write the compressed content to a file

Please see the doc page, which has some additional information: https://cloud.google.com/integration-connectors/docs/connectors/sftp/configure#examples