DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Can Datapower Zip the .CSV files Pulling from SFTP Poller

  • 1.  Can Datapower Zip the .CSV files Pulling from SFTP Poller

    Posted Fri January 22, 2021 06:42 AM

    HI Team ,

    I have requirement where i have to Pull a file sftp location then convert a file to .zip and then convert to a base64 and send base64 data to backend .

    Am able to pull a file from sftp puller and also able to call backend with .csv base64 data but need to call backed with .zip (CSV) base64 data .

    sftp location having csv files .

    Is the requirement is feasible if yes how we can achieve this .

    xslt which am using .

    <?xml version="1.0" encoding="UTF-8"?>

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:regexp="http://exslt.org/regular-expressions" extension-element-prefixes="dp regexp" exclude-result-prefixes="dp regexp" version="1.0">

    <dp:input-mapping href="store:///pkcs7-convert-input.ffd" type="ffd"/>

    <xsl:template match="/">

    <xsl:variable name="FrontsideFTP" select="dp:variable('var://service/URL-in')"/>

    <xsl:variable name="Filename" select="regexp:match($FrontsideFTP, '([^\/]*)$')"/>

    <xsl:variable name="Filename2" select="substring-before($Filename,'?Rename')"/>

    <xsl:variable name="BacksideFTP" select="concat('sftp://admin:Passw0rd!/home/admin/File1/',$Filename2)"/>

    <dp:set-variable name="'var://service/routing-url'" value="$BacksideFTP"/>

    <xsl:message dp:priority="debug">OId URL: <xsl:value-of select="$FrontsideFTP"/>

    </xsl:message>

    <xsl:message dp:priority="debug">Filename: <xsl:value-of select="$Filename"/>

    </xsl:message>

    <xsl:message dp:priority="debug">Filename2: <xsl:value-of select="$Filename2"/>

    </xsl:message>

    <xsl:message dp:priority="debug">New URL: <xsl:value-of select="$BacksideFTP"/>

    </xsl:message>

    <xsl:copy-of select="*"/>

    <xsl:variable name="response">

    <dp:url-open target="{$BacksideFTP}" response="ignore">

    <xsl:value-of select="dp:binary-encode(/object/message/node())"/>

    </dp:url-open>

    </xsl:variable>

    <xsl:message dp:priority="debug">responseL: <xsl:value-of select="$response"/>

    </xsl:message>

    <xsl:variable name="encdata" select="dp:binary-encode($Filename2)"/>

    <xsl:message dp:priority="debug">encdata: <xsl:value-of select="$encdata"/>

    </xsl:message>

    </xsl:template>

    </xsl:stylesheet>

    Regards ,

    Mayur



    #DataPower
    #Support
    #SupportMigration


  • 2.  RE: Can Datapower Zip the .CSV files Pulling from SFTP Poller

    Posted Wed February 03, 2021 03:40 PM

    Hi,

    you can create a zip file by combining a results action and a fetch action. First add a results action that takes in INPUT context and forwards it to for example:

    attachment://INPUT/cid:archive-zip?Archive=zip&Filename=testfile.csv

    Output context of the action can be just NULL. Then add a fetch action that takes in INPUT context and fetches the zipped attachment from:

    attachment://INPUT/cid:archive-zip?Encode=base64

    you then have to extract the the base64 encoded contents that is inside the resulted XML but that should be an easy task.

    --HP



    #DataPower
    #Support
    #SupportMigration